dateadd

Description

Returns the date produced by adding a given number of years, quarters, hours, or other date parts to the specified date.

Syntax

dateadd(date_part, integer, date)

Parameters

date_part

is a date part or abbreviation. For a list of the date parts and abbreviations recognized by Adaptive Server, see “Date parts”.

numeric

is an integer expression.

date

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.

Examples

Example 1

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 

Usage

Standards

SQL92 – Compliance level: Transact-SQL extension.

Permissions

Any user can execute dateadd.

See also

Datatypes Date and time datatypes

Commands select, where clause

Functions datediff, datename, datepart, getdate