meta data for this page
  •  

DATEADD()

Available in: DSQL, PSQL

Added in: 2.1

Description

Adds the specified number of years, months, days, hours, minutes, seconds or milliseconds to a date/time value.

Result type: DATE, TIME or TIMESTAMP:

Syntax

DATEADD (<args>)

<args>     ::= <amount> <unit> TO <datetime>
                | <unit>, <amount>, <datetime>

<amount>   ::= an integer expression (negative to subtract)
  <unit>   ::= YEAR | MONTH | DAY
                | HOUR | MINUTE | SECOND | MILLISECOND
<datetime> ::= a DATE, TIME or TIMESTAMP expression

* The result type is determined by the third argument.
* With <color #c3c3c3>DATE</color> arguments, only <color #c3c3c3>YEAR</color>, <color #c3c3c3>MONTH</color> and <color #c3c3c3>DAY</color> can be used.
* With <color #c3c3c3>TIME</color> arguments, only <color #c3c3c3>HOUR</color>, <color #c3c3c3>MINUTE</color>, <color #c3c3c3>SECOND</color> and <color #c3c3c3>MILLISECOND</color> can be used.

Examples

dateadd (28 day to current_date)
dateadd (-6 hour to current_time)
dateadd (month, 9, DateOfConception)
dateadd (minute, 90, time 'now')
dateadd (? year to date '11-Sep-1973')