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/timestamp.
Signatures
Returns: A new timestamp with the interval added
DATE_ADD(timestamp: TIMESTAMP, unit: VARCHAR, value: BIGINT) → TIMESTAMP sql
| Parameter | Type | Required | Description |
|---|---|---|---|
timestamp | TIMESTAMP | Yes | The base timestamp |
unit | VARCHAR | Yes | The time unit to add (e.g., 'day', 'hour', 'month') |
value | BIGINT | Yes | The number of units to add |
Notes
- Adds a specified interval to a timestamp
- Common units: 'second', 'minute', 'hour', 'day', 'week', 'month', 'year'
- Value can be positive (future) or negative (past)
- Useful for date arithmetic and scheduling
- Handles month/year boundaries correctly
Examples
FeatureQL
SELECT
f1 := DATE_ADD(TIMESTAMP '2024-03-15 10:00:00', 'day', 7), -- Add 7 days
f2 := DATE_ADD(TIMESTAMP '2024-03-15 10:00:00', 'hour', 3), -- Add 3 hours
f3 := DATE_ADD(TIMESTAMP '2024-03-15 10:00:00', 'month', -1) -- Subtract 1 month
;Result
| f1 TIMESTAMP | f2 TIMESTAMP | f3 TIMESTAMP |
|---|---|---|
| 2024-03-22T10:00:00 | 2024-03-15T13:00:00 | 2024-02-15T10:00:00 |
On this page