DATEADD function [Date and time]

Function

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

date part The date part to be added to the date.

For a complete listing of allowed date parts, see “Date parts”.

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.

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