Adding days or months to a date column

Bandi
Posted by Bandi under Sql Server category on | Points: 40 | Views : 774
Remember, whenever you required to add a month to a datetime column irrespective of 'day of month' better to use 1 MONTH option than 30 DAYS.

See the difference between adding 30 DAYS and 1 MONTH


SELECT DATEADD(month, 1, '2014-08-30') -- 2014-09-30 00:00:00.000
,DATEADD(DAY, 30, '2014-08-30') -- 2014-09-29 00:00:00.000
,DATEADD(month, 1, '2014-08-31') -- 2014-09-30 00:00:00.000
,DATEADD(DAY, 30, '2014-08-31') -- 2014-09-30 00:00:00.000

Comments or Responses

Login to post response