DATE_ADD()

All functions > DATE AND TIME > DATE_ADD()

Returns the date/timestamp after adding a given number of a given units to the given date or timestamp.

Signatures

Returns: A new DATE with the interval added

DATE_ADD(timestamp: DATE, unit: VARCHAR, value: BIGINT) → DATE
sql
ParameterTypeRequiredDescription
timestampDATEYesThe base date
unitVARCHARYesThe time unit to add (e.g., 'day', 'month')
valueBIGINTYesThe number of units to add

Returns: A new TIMESTAMP with the interval added

DATE_ADD(timestamp: TIMESTAMP, unit: VARCHAR, value: BIGINT) → TIMESTAMP
sql
ParameterTypeRequiredDescription
timestampTIMESTAMPYesThe base timestamp
unitVARCHARYesThe time unit to add (e.g., 'day', 'hour', 'month')
valueBIGINTYesThe number of units to add

Notes

  • Adds a specified interval to a date or timestamp
  • Common units: 'second', 'minute', 'hour', 'day', 'week', 'month', 'year'
  • Value can be positive (future) or negative (past)
  • DATE inputs return DATE; TIMESTAMP inputs return TIMESTAMP (type closure)
  • Useful for date arithmetic and scheduling
  • Handles month/year boundaries correctly

Examples

Date inputs

FeatureQL
SELECT
    -- Add 7 days to a date
    f1 := DATE_ADD(DATE '2024-03-15', 'day', 7),
    -- Add 2 months to a date
    f2 := DATE_ADD(DATE '2024-03-15', 'month', 2)
;
Result
f1 TIMESTAMPf2 TIMESTAMP
2024-03-222024-05-15

Timestamp inputs

FeatureQL
SELECT
    -- Add 7 days
    f1 := DATE_ADD(TIMESTAMP '2024-03-15 10:00:00', 'day', 7),
    -- Add 3 hours
    f2 := DATE_ADD(TIMESTAMP '2024-03-15 10:00:00', 'hour', 3),
    -- Subtract 1 month
    f3 := DATE_ADD(TIMESTAMP '2024-03-15 10:00:00', 'month', -1)
;
Result
f1 TIMESTAMPf2 TIMESTAMPf3 TIMESTAMP
2024-03-22T10:00:002024-03-15T13:00:002024-02-15T10:00:00