DATEADD: add or subtract a number of days, months, or years from a specific date : DATEADD « Date Timezone « SQL Server / T-SQL





DATEADD: add or subtract a number of days, months, or years from a specific date


1>
2> -- DATEADD: add or subtract a number of days, months, or years from a specific date.
3>
4>
5> -- Add 12 days to 24th March 1964
6>
7> SELECT DATEADD(dd,12,"24 March 1964")
8>
9> SELECT DATEADD(d,12,"24 March 1964")
10> GO

-----------------------
1964-04-05 00:00:00.000

(1 rows affected)

-----------------------
1964-04-05 00:00:00.000

(1 rows affected)
1>
           
       










Related examples in the same category

1.SELECT DATEADD(yy,12,"24 March 1964"): Add 12 years to 24th March 1964
2.SELECT DATEADD(m,12,"24 March 1964"): Add 12 months to 24th March 1964
3.SELECT DATEADD(wk,12,"24 March 1964"): Add 12 weeks to 24th March 1964
4.SELECT DATEADD(hh,12,"24 March 1964"): Add 12 hours to 24th March 1964
5.Add 12 minutes to 24th March 1964
6.DATEADD(Day, 90, '4-29-1988'): adds a specific number of date unit intervals to a date/time value
7.DATEADD(year, 18, '4-29-1988 10:30 AM'): 18 years later
8.DATEADD(yy, -18, '4-29-1988 10:30 AM'): 18 years before
9.DATEADD(second, 9000, '4-29-1988 10:30 AM'): 9,000 seconds after
10.DATEADD(mi, -9000000, '4-29-1988 10:30 AM'): 9,000,000 milliseconds before
11.SELECT DATEADD(dayofyear, 18, '4-29-1988 10:30 AM')
12.SELECT DATEADD(quarter, 18, '4-29-1988 10:30 AM')
13.Combine the CONVERT()and the DATEADD() functions to format a return date value nine months before September 8, 1989
14.SELECT DATEADD(mi, -30, '2005-09-01 23:30:00.000')
15.select DATEADD(month, -1, '2002-09-30 11:35:00')
16.DATEADD: add days to a date
17.Combine DateADD and DateDIFF to get the last date of a month