Request a demo

BigQuery · Timestamp function

BigQuery FORMAT_TIMESTAMP

FORMAT_TIMESTAMP(format_string, ts[, time_zone]) converts a TIMESTAMP to a STRING with % elements, in UTC or in the zone you pass: FORMAT_TIMESTAMP('%F %H:%M', ts, 'Europe/Berlin'). It is the standard way to turn a timestamp into a local-time string.

GoogleSQL for BigQuery · Checked against the official reference in November 2026

FORMAT_TIMESTAMP prints an instant as text. The optional third argument decides which zone's wall clock is printed; without it the output is UTC. Besides the date and time elements shared with FORMAT_DATETIME, it supports zone elements: %z prints the offset as +0530, %Ez as +05:30 (RFC 3339), and %Z the zone as BigQuery names it, such as UTC or UTC-5, not abbreviations like EST.

Common layouts: '%Y-%m-%dT%H:%M:%SZ' for ISO 8601 in UTC, '%Y-%m-%dT%H:%M:%E3S%Ez' for ISO with milliseconds and an offset, '%F %T' for 2026-11-23 15:30:00, and '%s' for epoch seconds as text.

CAST(ts AS STRING) is the quick alternative and returns 2026-11-23 15:30:00+00; STRING(ts, 'Asia/Tokyo') does the same in another zone. Use FORMAT_TIMESTAMP when the consumer needs a specific layout.

Syntax

FORMAT_TIMESTAMP(format_string, timestamp_expr[, time_zone])

Arguments and return value

ArgumentDescription
format_stringA STRING of format elements and literal text.
timestamp_exprThe TIMESTAMP to format. NULL returns NULL.
time_zoneOptional zone name or offset whose local time is printed. Defaults to UTC.

Returns: STRING

Examples

ISO 8601 and other common layouts

SELECT
  FORMAT_TIMESTAMP('%Y-%m-%dT%H:%M:%SZ', TIMESTAMP '2026-11-23 15:30:00+00') AS iso_utc,
  FORMAT_TIMESTAMP('%F %T', TIMESTAMP '2026-11-23 15:30:00+00') AS sql_style,
  FORMAT_TIMESTAMP('%c', TIMESTAMP '2026-11-23 15:30:00+00') AS readable,
  CAST(TIMESTAMP '2026-11-23 15:30:00+00' AS STRING) AS cast_default;
Result
iso_utcsql_stylereadablecast_default
2026-11-23T15:30:00Z2026-11-23 15:30:00Mon Nov 23 15:30:00 20262026-11-23 15:30:00+00

Local time with the zone or offset

SELECT
  FORMAT_TIMESTAMP('%Y-%m-%d %H:%M %Z', TIMESTAMP '2026-11-23 15:30:00+00', 'America/New_York') AS new_york,
  FORMAT_TIMESTAMP('%H:%M%Ez', TIMESTAMP '2026-11-23 15:30:00+00', 'Europe/Berlin') AS berlin_rfc3339,
  FORMAT_TIMESTAMP('%H:%M %z', TIMESTAMP '2026-11-23 15:30:00+00', 'Asia/Kolkata') AS kolkata;
Result
new_yorkberlin_rfc3339kolkata
2026-11-23 10:30 UTC-516:30+01:0021:00 +0530

Milliseconds for APIs and logs

SELECT
  FORMAT_TIMESTAMP('%Y-%m-%dT%H:%M:%E3SZ', TIMESTAMP '2026-11-23 15:30:00.123456+00') AS iso_millis,
  FORMAT_TIMESTAMP('%Y-%m-%dT%H:%M:%E*S%Ez', TIMESTAMP '2026-11-23 15:30:00.123456+00', 'Europe/Berlin') AS iso_micros_berlin;
Result
iso_millisiso_micros_berlin
2026-11-23T15:30:00.123Z2026-11-23T16:30:00.123456+01:00

Local hour labels for a report

WITH orders AS (
  SELECT TIMESTAMP '2026-11-23 07:10:00+00' AS created_at UNION ALL
  SELECT TIMESTAMP '2026-11-23 07:50:00+00' UNION ALL
  SELECT TIMESTAMP '2026-11-23 12:20:00+00'
),
hourly AS (
  SELECT TIMESTAMP_TRUNC(created_at, HOUR, 'Europe/Berlin') AS hour, COUNT(*) AS orders
  FROM orders
  GROUP BY hour
)
SELECT FORMAT_TIMESTAMP('%H:00', hour, 'Europe/Berlin') AS berlin_hour, orders
FROM hourly
ORDER BY hour;
Result
berlin_hourorders
08:002
13:001

Common mistakes

  • Forgetting the zone argument. Without it the string is UTC, which shifts hours and sometimes dates for local reports.
  • Expecting %Z to print EST or CET. BigQuery prints names such as UTC-5 or UTC+1; print the offset with %Ez or add the zone name as literal text.
  • Formatting the partition column in WHERE. Only %F, %Y-%m-%d and %Y%m%d keep partition pruning; other layouts scan every partition.
  • Porting TO_CHAR(ts AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS') from PostgreSQL. Use FORMAT_TIMESTAMP with % elements, or CAST(ts AS STRING FORMAT ... AT TIME ZONE ...).

Cost and performance

  • BigQuery's partition pruning guide lists FORMAT_TIMESTAMP with %F, %Y-%m-%d or %Y%m%d as safe to use on the partitioning column. Any other format string in a filter forces a scan of all partitions.

FAQ

How do I convert a timestamp to a string in BigQuery?

CAST(ts AS STRING) returns 2026-11-23 15:30:00+00. For any other layout or a local zone, use FORMAT_TIMESTAMP('%F %T', ts, 'America/Chicago').

How do I format a timestamp as ISO 8601?

FORMAT_TIMESTAMP('%Y-%m-%dT%H:%M:%SZ', ts) for UTC, or FORMAT_TIMESTAMP('%Y-%m-%dT%H:%M:%S%Ez', ts, zone) with a local offset. Add %E3S instead of %S for milliseconds.

How do I show a timestamp in a different time zone?

Pass the zone as the third argument: FORMAT_TIMESTAMP('%F %H:%M', ts, 'Australia/Sydney'). For a DATETIME value instead of a string, use DATETIME(ts, 'Australia/Sydney').

Errors you may hit

More timestamp functions

All BigQuery timestamp functions · All functions · BigQuery error messages

Observability for every BigQuery table, in about 15 minutes

Masthead detects freshness, volume and schema anomalies, monitors pipeline errors and maps column-level lineage across all your projects, from logs and metadata only.