date_add
NULL amount or date/timestamp input returns NULL. Values outside the supported range can raise an error.
Syntax
Dateadd units (scalar)
- DATEADD uses a unit keyword such as DAY; do not quote it as a STRING literal.
Arguments
Returns
- Type: TIMESTAMP
- NULL behavior: NULL amount or date/timestamp input returns NULL. Values outside the supported range can raise an error.
Properties
Units
- Input unit: The unit keyword in the first argument
- Output unit: Temporal value
Usage notes
- In the three-argument form, numeric amounts are converted to BIGINT before addition. Fractional amounts are truncated toward zero: 1.9 adds one unit, and -1.9 subtracts one unit.
- DATE input in the three-argument form becomes a midnight TIMESTAMP, so hours and smaller units can change its time of day.
- TIME inputs are not accepted by these calling forms. Use a DATE or TIMESTAMP value.
- INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.
Examples
Alias calling form: DATEADD
Fractional amounts are truncated toward zero:
Limitations
- The three-argument form returns TIMESTAMP, including for a DATE input.
- Amounts must fit BIGINT after conversion, and the resulting date or timestamp must remain within its supported range. Do not rely on NULL being returned for overflow.