dateadd

Adds or subtracts a certain duration of time to an existing date or time value.

Function

result = dateadd(period, count, input)

Arguments

ArgumentData Type
perioddatepart
countinteger
inputdate or time or datetime
resultdate or time or datetime

Comments

Adds count of period to input. To subtract use a negative value for count.

datepart can be one of the following, specified as the word without quotes: year, quarter, month, week, day, hour, minute, second

This function operates in the local time-zone if a datetime input is provided. See Dates, Times and Time Zones.

Examples

result = dateadd(year, 1, getdate()) /* 1 year from today */