Firebird Documentation IndexFirebird 2.5 Language Ref. UpdateInternal functions → DATEADD()
Firebird Home Firebird Home Prev: COT()Firebird Documentation IndexUp: Internal functionsNext: DATEDIFF()

DATEADD()

Tip

Find a more recent version at Firebird 5.0 Language Reference: DATEADD()

Available in: DSQL, PSQL

Added in: 2.1

Changed in: 2.5

Description: Adds the specified number of years, months, weeks, days, hours, minutes, seconds or milliseconds to a date/time value. (The WEEK unit is new in 2.5.)

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 | WEEK | DAY
                   | HOUR | MINUTE | SECOND | MILLISECOND
<datetime>  ::=  a DATE, TIME or TIMESTAMP expression
  • The result type is determined by the third argument.

  • With TIMESTAMP and DATE arguments, all units can be used. (Prior to Firebird 2.5, units smaller than DAY were disallowed for DATEs.)

  • With TIME arguments, only HOUR, MINUTE, SECOND and MILLISECOND can be used.

Examples: 

dateadd (28 day to current_date)
dateadd (-6 hour to current_time)
dateadd (month, 9, DateOfConception)
dateadd (-38 week to DateOfBirth)
dateadd (minute, 90, time 'now')
dateadd (? year to date '11-Sep-1973')
Prev: COT()Firebird Documentation IndexUp: Internal functionsNext: DATEDIFF()
Firebird Documentation IndexFirebird 2.5 Language Ref. UpdateInternal functions → DATEADD()