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, count: BIGINT, unit: VARCHAR) → DATE
sql
ParameterTypeRequiredDescription
timestampDATEYesThe base date
countBIGINTYesThe number of units to add
unitVARCHARYesThe time unit to add (e.g., 'day', 'month') compile-time

Returns: A new TIMESTAMP with the interval added

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

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
RETURN
    -- Add 7 days to a date
    f1 := DATE_ADD(DATE '2024-03-15', 7, 'day'),
    -- Add 2 months to a date
    f2 := DATE_ADD(DATE '2024-03-15', 2, 'month')
;
Result
f1 TIMESTAMPf2 TIMESTAMP
2024-03-222024-05-15

Timestamp inputs

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