BigQuery · Datetime function
BigQuery DATETIME_ADD
DATETIME_ADD(datetime, INTERVAL n part) adds microseconds up to years to a DATETIME and returns a DATETIME. It works on wall-clock time, so adding 1 DAY keeps the same local hour even across a daylight saving change.
DATETIME_ADD moves a DATETIME forward by any of MICROSECOND, MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER or YEAR. Negative amounts move backwards. Month, quarter and year steps clamp to the end of shorter months, so January 31 plus one month is February 28 (or 29).
Because DATETIME has no time zone, the arithmetic is on the calendar and clock alone. That is the difference from TIMESTAMP_ADD: adding INTERVAL 1 DAY to 12:00 on the day before clocks fall back gives 12:00 the next day with DATETIME_ADD, but 11:00 local time with TIMESTAMP_ADD, which adds exactly 24 hours.
TIMESTAMP_ADD also refuses MONTH, QUARTER and YEAR. The standard workaround is to convert to DATETIME in the zone that defines "a month" for you, use DATETIME_ADD, and convert back with TIMESTAMP(..., zone).
Syntax
DATETIME_ADD(datetime_expression, INTERVAL step_size step_unit)Arguments and return value
| Argument | Description |
|---|---|
datetime_expression | The DATETIME to shift. |
step_size | An INT64 number of units; negative values move backwards. |
step_unit | MICROSECOND, MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER or YEAR. |
Returns: DATETIME
Examples
Add minutes, days and months
SELECT
DATETIME_ADD(DATETIME '2026-11-23 18:45:00', INTERVAL 90 MINUTE) AS plus_90_min,
DATETIME_ADD(DATETIME '2026-11-23 18:45:00', INTERVAL 1 DAY) AS plus_1_day,
DATETIME_ADD(DATETIME '2026-11-23 18:45:00', INTERVAL 1 MONTH) AS plus_1_month;| plus_90_min | plus_1_day | plus_1_month |
|---|---|---|
| 2026-11-23T20:15:00 | 2026-11-24T18:45:00 | 2026-12-23T18:45:00 |
Month-end clamping
SELECT DATETIME_ADD(DATETIME '2026-01-31 09:00:00', INTERVAL 1 MONTH) AS next_billing_run;| next_billing_run |
|---|
| 2026-02-28T09:00:00 |
Wall-clock day versus 24 hours across a DST change
New York leaves daylight saving time on November 1, 2026. 24 hours after noon is 11:00 local (16:00 UTC); noon local on November 1 is 17:00 UTC.
SELECT
TIMESTAMP_ADD(TIMESTAMP '2026-10-31 12:00:00 America/New_York', INTERVAL 1 DAY) AS plus_24_hours,
TIMESTAMP(DATETIME_ADD(DATETIME '2026-10-31 12:00:00', INTERVAL 1 DAY), 'America/New_York') AS same_local_time_next_day;| plus_24_hours | same_local_time_next_day |
|---|---|
| 2026-11-01 16:00:00 UTC | 2026-11-01 17:00:00 UTC |
Add a month to a TIMESTAMP via DATETIME
TIMESTAMP_ADD(ts, INTERVAL 1 MONTH) fails with "TIMESTAMP_ADD does not support the MONTH date part when the argument is TIMESTAMP type".
SELECT
TIMESTAMP(
DATETIME_ADD(DATETIME(TIMESTAMP '2026-11-23 18:45:00+00', 'Europe/Berlin'), INTERVAL 1 MONTH),
'Europe/Berlin'
) AS renews_at;| renews_at |
|---|
| 2026-12-23 18:45:00 UTC |
Common mistakes
- Expecting DATETIME_ADD to know about DST. It adds to the clock reading; if the result is a local time, the real elapsed time can be 23 or 25 hours.
- Passing a TIMESTAMP and expecting a TIMESTAMP. Use TIMESTAMP_ADD for fixed durations, or convert explicitly with DATETIME(ts, zone) as in the example.
- Writing
DATEADD(hour, 2, dt)ordt + INTERVAL '2 hours'. In BigQuery useDATETIME_ADD(dt, INTERVAL 2 HOUR)ordt + INTERVAL 2 HOUR(both return DATETIME).
FAQ
How do I add hours to a datetime in BigQuery?
DATETIME_ADD(dt, INTERVAL 3 HOUR) or dt + INTERVAL 3 HOUR; both return a DATETIME.
How do I add months to a timestamp in BigQuery?
Convert to DATETIME in a zone, add the months and convert back: TIMESTAMP(DATETIME_ADD(DATETIME(ts, 'UTC'), INTERVAL 1 MONTH), 'UTC'). TIMESTAMP_ADD doesn't accept MONTH or YEAR.
What is the difference between DATETIME_ADD and TIMESTAMP_ADD?
DATETIME_ADD changes a wall-clock reading and supports months and years. TIMESTAMP_ADD adds an exact duration (up to DAY = 24 hours) to an instant.
Related
Errors you may hit
More datetime functions
All BigQuery datetime functions · All functions · BigQuery error messages
