To get the current date in Sql Server queries and stored procedures, you use the GetDate() method. But what about to add a day or two to the current date, or add a month or years? To do it, you use the following query:
Add One Day
SELECT DateAdd(dd, 1, GetDate())
Add One Month
SELECT DateAdd(mm, 1, GetDate())
Add One Year
SELECT DateAdd(yy, 1, GetDate())
To subtract a day, month or year, instead of 1, insert -1, thus to subtract 1 month use the following:
SELECT DateAdd(mm, -1, GetDate())
References here
One Response
Short and good description….
Very helpfull