Sunday, February 19, 2012

add and subract time to a date

Hello all,
Lets say I have the current date and I would like to get the date
two weeks in advance. How would I do this in T-sql? The T-SQL should
take into account if the month changes. For example, if todays date
is 1/17/2003 the advanced date would be 2/17/2003.

Thanks,
BillyYou can use DATEADD function to accomplish this. Refer to SQL Server Books
Online for more details. For example :

SELECT DATEADD(m, 1, '20030117') ;

--
- Anith
( Please reply to newsgroups only )

No comments:

Post a Comment