DATEADD(date_part, number_interval, specified_date)date_part is the parameter that specifies on which part of the date to be manipulated with the number interval. You can add month, year, day and etc. You can use
MONTH, MM or M for monthFor example :
YEAR, YYYY, YY for year
DAY, DD, D for day
HH for hour
SS, S for Second
SELECT DATEADD(D, -1, GETDATE())AS [Yesterday]
SELECT DATEADD(MM, 3, GETDATE())AS [FourMonthsFromNow]
SELECT DATEADD(YEAR, -2, GETDATE())AS [TwoYearsAgo]
0 comments:
Post a Comment