Skip to main content

DATEADD

Returns the specified date with the specified number interval added to the specified date_part of that date.

SYNTAX​

    DATEADD(date_part, interval, date)

ARGUMENTS​

date_part The units in which DATEADD reports the sum of startdate and enddate.

Note: Valid datepart arguments { year:"yy", quarter:"q", month:"mm", day:"dd", hour:"hh", minute:"mi", second:"s", millisecond:"ms" and "ns" }.

interval
A value of Numeric or Float data type category.

date
A value of the Date & Time data type category.

Return Value​

Returns a DATETIME value.

Examples​

Examples in this section use the example blockchain.

A. Simple part addition​

This example adds 3 days to the DATETIME argument.

SELECT DATEADD("dd", 3, DATETIME("2021-05-12 00:00:00"));

Response:

DATEADD("dd", 3, DATETIME("2021-05-12 00:00:00")) [DATETIME]
2021-05-15 00:00:00

B. Out of range behavior​

The date argument is of type DATE and doesn't support a minute value. Nevertheless, because DATEADD returns a DATETIME value, a single minute is added.

SELECT DATEADD("mi", 1, DATE("2021-05-12")) FROM example;

Response:

DATEADD("mi", 1, DATE("2021-05-12")) [DATETIME]
2021-05-15 00:01:00