DATEADD#

Returns a specified date with the specified number interval (signed integer) added to a specified datepart of that date.

Syntax#

DATEADD (datepart , number , date )

Arguments#

datepart

Is the part of date to which an integer number is added. The following table lists all valid datepart arguments. User-defined variable equivalents are not valid.

datepart

Abbreviations

year

yy, yyyy

quarter

qq, q

month

mm, m

dayofyear

dy, y

day

dd, d

week

wk, ww

weekday

dw, w

hour

hh

minute

mi, n

second

ss, s

millisecond

ms

microsecond

mcs

nanosecond

ns

number

Is an expression that can be resolved to an int that is added to a datepart of date. User-defined variables are valid. If you specify a value with a decimal fraction, the fraction is truncated and not rounded.

date

Is an expression that can be resolved to a time, date, smalldatetime, datetime, datetime2, or datetimeoffset value. date can be an expression, column expression, user-defined variable, or string literal. If the expression is a string literal, it must resolve to a datetime. To avoid ambiguity, use four-digit years.

Return types#

The return data type is the data type of the date argument, except for string literals. The return data type for a string literal is datetime.

Example#

SELECT DATEADD(hour, 23, '2007-10-30 12:15:32')

See Also#