DATEADD Function [Date and Time]

Returns the date produced by adding the specified number of the specified date parts to a date.

Syntax

DATEADDdate-part, numeric-expression, date-expression )

Parameters

Parameter

Description

date part

The date part to be added to the date.

numeric-expression

The number of date parts to be added to the date. The numeric-expression can be any numeric type; the value is truncated to an integer. The maximum microsecond in numeric-expression is 2147483647, that is, 35:47.483647 (35 mins 47 secs 483647 mcs).

date-expression

The date to be modified.

Returns

TIMESTAMP

Example

The following statement returns the value 1995-11-02 00:00:00.000:
SELECT DATEADD( MONTH, 102, '1987/05/02' ) FROM iq_dummy
The following statement returns the value 2009-11-10 14:57:52.722016:
SELECT DATEADD(MICROSECOND, 15, '2009-11-10
14:57:52.722001') FROM iq_dummy
The following statement returns the value 1985-05-02 00:00:00.123456:
SELECT DATEADD(MICROSECOND, 123456, '1985/05/02')
FROM iq_dummy
The following statement returns the value 1985-05-01 23:59:59.876544:
SELECT DATEADD(MICROSECOND, -123456, '1985/05/02')
FROM iq_dummy
The following statement returns the value 2009-11-03 11:10:42.033192:
SELECT DATEADD(MCS, 2, '2009-11-03 11:10:42.033190')
FROM iq_dummy

Usage

DATEADD is a Transact-SQL compatible data manipulation function.

Standards and Compatibility

  • SQL—Transact-SQL extension to ISO/ANSI SQL grammar.

  • Sybase—Compatible with Adaptive Server Enterprise.

Related reference
DATECEILING Function [Date and Time]
DATEDIFF Function [Date and Time]
DATEFLOOR Function [Date and Time]
DATEPART Function [Date and Time]
DATENAME Function [Date and Time]
DATEROUND Function [Date and Time]
Date Parts