Returns the date produced by adding a given number of years, quarters, hours, or other date parts to the specified date.
dateadd(date_part, integer, date)
is a date part or abbreviation. For a list of the date parts and abbreviations recognized by Adaptive Server, see “Date parts”.
is an integer expression.
is either the function getdate, a character string in one of the acceptable date formats, an expression that evaluates to a valid date format, or the name of a datetime column.
Displays the new publication dates when the publication dates of all the books in the titles table slip by 21 days:
select newpubdate = dateadd(day, 21, pubdate) from titles
dateadd, a date function, adds an interval to a specified date. For more information about date functions, see “Date functions”.
dateadd takes three arguments: the date part, a number, and a date. The result is a datetime value equal to the date plus the number of date parts.
If the date argument is a smalldatetime value, the result is also a smalldatetime. You can use dateadd to add seconds or milliseconds to a smalldatetime, but it is meaningful only if the result date returned by dateadd changes by at least one minute.
Use the datetime datatype only for dates after January 1, 1753. datetime values must be enclosed in single or double quotes. Use char, nchar, varchar or nvarchar for earlier dates. Adaptive Server recognizes a wide variety of date formats. For more information, see “User-defined datatypes” and “Datatype conversion functions”.
Adaptive Server automatically converts between character and datetime values when necessary (for example, when you compare a character value to a datetime value).
Using the date part weekday or dw with dateadd is not logical, and produces spurious results. Use day or dd instead.
SQL92 – Compliance level: Transact-SQL extension.
Any user can execute dateadd.
Datatypes Date and time datatypes
Commands select, where clause
Functions datediff, datename, datepart, getdate