SQL > SQL Date Functions > Dateadd Function

The DATEADD function is used to add an interval to a date. This function is available in SQL Server.

The usage for the DATEADD function is

DATEADD (datepart, number, expression)

where the data type of <expression> is some type of date, time, or datetime. <number> is an integer (can be positive or negative). <datepart> can be one of the following:

datepartabbreviation
yearyy, yyyy
quarterqq, q
monthmm, m
dayofyeardy, y
daydd, d
weekwk, ww
hourhh
minutemi, n
secondss, s
millisecondms
microsecondmcs
nanosecondns
TZoffsettz
ISO_WEEKisowk, isoww

The result returned has the same data type as <expression>.

Example: The SQL statement

SELECT DATEADD (day, 10, '2000-01-05 00:05:00.000');

yields the following result:

'2000-01-15 00:05:00.000'

Next: SQL DATEDIFF




Copyright © 2014 1keydata.com   All Rights Reserved.   Privacy Policy