Mega Code Archive

 
Categories / MSSQL Tutorial / Date Functions
 

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

To subtract days, use a negative number in the second parameter 9> SELECT DATEADD(dd,12,"24 March 1964") 10> GO ----------------------- 1964-04-05 00:00:00.000 (1 rows affected) The syntax for DATEADD requires 3 parameters. DATEADD(what_to_add,number_to_add,date_to_add_it_to) The first parameter can define what you are wishing to add to the date.