BigQuery · Timestamp function
BigQuery TIMESTAMP
TIMESTAMP converts a STRING, DATE or DATETIME to a TIMESTAMP, reading it in UTC or in the time zone you pass: TIMESTAMP('2026-11-23 09:00:00', 'Europe/Berlin') is 08:00 UTC. Use it to turn local times into absolute instants.
TIMESTAMP builds an absolute instant. From a STRING it accepts the canonical layout with an optional offset or zone name inside the string ('2026-11-23 18:45:00+01', '2026-11-23T18:45:00Z', '2026-11-23 18:45:00 America/Chicago'). From a DATE it returns midnight at the start of that day; from a DATETIME it reads the wall-clock value.
The optional second argument says which zone the input is written in; without it, UTC is assumed. TIMESTAMP(DATETIME '2026-11-23 09:00:00', 'Europe/Berlin') returns 2026-11-23 08:00:00 UTC. If the string already contains an offset, don't pass a zone as well: that fails with "Timezone is not allowed in ...".
DATETIME vs TIMESTAMP: a TIMESTAMP is a point on the global timeline (stored as microseconds since 1970-01-01 UTC) and is what you should store for events. The console displays it in UTC. DATETIME is a zone-less calendar and clock reading. TIMESTAMP(dt, zone) and DATETIME(ts, zone) convert between them. For other string layouts use PARSE_TIMESTAMP.
Syntax
TIMESTAMP(string_expression[, time_zone])
TIMESTAMP(date_expression[, time_zone])
TIMESTAMP(datetime_expression[, time_zone])Arguments and return value
| Argument | Description |
|---|---|
string_expression | A timestamp literal string such as '2026-11-23 18:45:00', optionally with an offset or zone name inside it. |
date_expression | A DATE; the result is the first instant of that day in the zone. |
datetime_expression | A DATETIME read as wall-clock time in the zone. |
time_zone | Optional STRING zone name or offset that the input is written in. Defaults to UTC. Not allowed when the string already has a zone. |
Returns: TIMESTAMP
Examples
Strings with and without offsets
SELECT
TIMESTAMP('2026-11-23 18:45:00') AS assumed_utc,
TIMESTAMP('2026-11-23 18:45:00+01') AS with_offset,
TIMESTAMP('2026-11-23 18:45:00', 'America/New_York') AS new_york,
TIMESTAMP('2026-11-23T18:45:00Z') AS zulu;| assumed_utc | with_offset | new_york | zulu |
|---|---|---|---|
| 2026-11-23 18:45:00 UTC | 2026-11-23 17:45:00 UTC | 2026-11-23 23:45:00 UTC | 2026-11-23 18:45:00 UTC |
From DATE and DATETIME in a zone
SELECT
TIMESTAMP(DATE '2026-11-23') AS utc_midnight,
TIMESTAMP(DATE '2026-11-23', 'Asia/Tokyo') AS tokyo_midnight,
TIMESTAMP(DATETIME '2026-11-23 09:00:00', 'Europe/Berlin') AS berlin_nine_am;| utc_midnight | tokyo_midnight | berlin_nine_am |
|---|---|---|
| 2026-11-23 00:00:00 UTC | 2026-11-22 15:00:00 UTC | 2026-11-23 08:00:00 UTC |
Filter a TIMESTAMP column by a local calendar day
November 23 in New York runs from 05:00 UTC to 05:00 UTC the next day. Comparing the raw column with constant bounds keeps partition pruning.
WITH events AS (
SELECT 'e1' AS event_id, TIMESTAMP '2026-11-23 04:30:00+00' AS event_ts UNION ALL
SELECT 'e2', TIMESTAMP '2026-11-23 06:00:00+00' UNION ALL
SELECT 'e3', TIMESTAMP '2026-11-24 04:59:59+00'
)
SELECT event_id
FROM events
WHERE event_ts >= TIMESTAMP(DATE '2026-11-23', 'America/New_York')
AND event_ts < TIMESTAMP(DATE '2026-11-24', 'America/New_York')
ORDER BY event_id;| event_id |
|---|
| e2 |
| e3 |
Offset in the string plus a zone argument fails
BigQuery rejects this with "Timezone is not allowed in \"2026-11-23 10:00:00+01\"". Drop one of the two.
SELECT TIMESTAMP('2026-11-23 10:00:00+01', 'America/New_York') AS conflicting;Common mistakes
- Assuming a string without an offset is local time.
TIMESTAMP('2026-11-23 09:00:00')is 09:00 UTC; pass the zone if the text is local. - Passing a zone when the string already has one. That fails with "Timezone is not allowed in ...".
- Using a fixed offset for a DST zone.
'-05'is New York only in winter;'America/New_York'follows the rules. - Expecting the console to show local time. A TIMESTAMP is always displayed in UTC; convert with DATETIME(ts, zone) or FORMAT_TIMESTAMP for local output.
- Comparing a TIMESTAMP column with a non-canonical string literal such as
'23/11/2026'. It fails with Could not cast literal.
Cost and performance
- Filter TIMESTAMP-partitioned tables with constant bounds built by TIMESTAMP(), as in the local-day example. BigQuery evaluates them once and prunes partitions; wrapping the column in a conversion instead can force a full scan.
FAQ
What is the difference between DATETIME and TIMESTAMP in BigQuery?
TIMESTAMP is an absolute instant, displayed in UTC. DATETIME is a calendar date and clock time without a zone. Store events as TIMESTAMP; use DATETIME for local business times.
How do I convert a datetime to a timestamp?
TIMESTAMP(dt, 'Europe/Paris') treats the DATETIME as Paris wall-clock time. Without the zone it is read as UTC.
How do I convert a string to a timestamp?
TIMESTAMP('2026-11-23 18:45:00+01') or CAST(s AS TIMESTAMP) for the canonical layout; PARSE_TIMESTAMP for any other layout.
Does a TIMESTAMP store the time zone?
No. It stores the instant only. The zone in a literal or argument is used to compute that instant and then discarded.
Related
Errors you may hit
More timestamp functions
All BigQuery timestamp functions · All functions · BigQuery error messages
