Request a demo

BigQuery · Date function

BigQuery EXTRACT

EXTRACT(part FROM value) returns one part of a DATE, DATETIME, TIMESTAMP or TIME, such as YEAR, MONTH, DAYOFWEEK, ISOWEEK or HOUR, usually as INT64. For a TIMESTAMP, add AT TIME ZONE to read the part in local time.

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

EXTRACT pulls a single field out of a date or time value. EXTRACT(MONTH FROM order_date) returns 11 for any day in November, which makes it useful for seasonality ("orders by weekday", "traffic by hour"), but it drops everything else, so don't use it alone to group a series that spans several years.

The parts depend on the input type. DATE accepts DAYOFWEEK, DAY, DAYOFYEAR, WEEK, WEEK(<WEEKDAY>), ISOWEEK, MONTH, QUARTER, YEAR and ISOYEAR. DATETIME adds MICROSECOND, MILLISECOND, SECOND, MINUTE, HOUR, DATE and TIME. TIMESTAMP adds DATETIME as well, and TIME accepts only HOUR down to MICROSECOND. DATE, TIME and DATETIME return those types; every other part returns INT64.

DAYOFWEEK runs from 1 (Sunday) to 7 (Saturday). WEEK numbers Sunday-based weeks from 0: days before the year's first Sunday are week 0. ISOWEEK follows ISO 8601 (Monday weeks, numbered 1 to 53, week 1 contains the first Thursday) and pairs with ISOYEAR, which can differ from YEAR in the last days of December and the first days of January. On a TIMESTAMP, EXTRACT(HOUR FROM ts AT TIME ZONE 'Europe/Berlin') reads the local hour; without AT TIME ZONE every part is read in UTC.

Syntax

EXTRACT(part FROM date_expression)

EXTRACT(part FROM datetime_expression)

EXTRACT(part FROM timestamp_expression [AT TIME ZONE time_zone])

EXTRACT(part FROM time_expression)

Arguments and return value

ArgumentDescription
partUnquoted: YEAR, ISOYEAR, QUARTER, MONTH, WEEK, WEEK(<WEEKDAY>), ISOWEEK, DAY, DAYOFYEAR, DAYOFWEEK, HOUR, MINUTE, SECOND, MILLISECOND, MICROSECOND, DATE, TIME or DATETIME, depending on the input type.
valueA DATE, DATETIME, TIMESTAMP or TIME expression.
time_zoneTIMESTAMP only: a time zone name or offset used to read the part, for example 'America/New_York'. Defaults to UTC.

Returns: INT64, except DATE for the DATE part, TIME for TIME and DATETIME for DATETIME.

Examples

Calendar parts of a date

2026-11-23 is a Monday, so DAYOFWEEK is 2 (Sunday is 1).

SELECT
  EXTRACT(YEAR FROM DATE '2026-11-23') AS year,
  EXTRACT(QUARTER FROM DATE '2026-11-23') AS quarter,
  EXTRACT(MONTH FROM DATE '2026-11-23') AS month,
  EXTRACT(DAY FROM DATE '2026-11-23') AS day,
  EXTRACT(DAYOFWEEK FROM DATE '2026-11-23') AS day_of_week,
  EXTRACT(DAYOFYEAR FROM DATE '2026-11-23') AS day_of_year;
Result
yearquartermonthdayday_of_weekday_of_year
2026411232327

WEEK, WEEK(MONDAY), ISOWEEK and ISOYEAR around New Year

January 1, 2026 is a Thursday, so ISO week 1 of 2026 starts on Monday, December 29, 2025. The Sunday-based WEEK starts counting at 1 on Sunday, January 4.

SELECT
  d,
  EXTRACT(WEEK FROM d) AS week,
  EXTRACT(WEEK(MONDAY) FROM d) AS week_monday,
  EXTRACT(ISOWEEK FROM d) AS isoweek,
  EXTRACT(YEAR FROM d) AS year,
  EXTRACT(ISOYEAR FROM d) AS isoyear
FROM UNNEST([DATE '2025-12-29', DATE '2026-01-01', DATE '2026-01-04', DATE '2026-01-05']) AS d
ORDER BY d;
Result
dweekweek_mondayisoweekyearisoyear
2025-12-295252120252026
2026-01-0100120262026
2026-01-0410120262026
2026-01-0511220262026

Local hour and date of a timestamp with AT TIME ZONE

In New York the event happened at 22:30 on Sunday, November 22.

SELECT
  EXTRACT(HOUR FROM TIMESTAMP '2026-11-23 03:30:00+00') AS utc_hour,
  EXTRACT(HOUR FROM TIMESTAMP '2026-11-23 03:30:00+00' AT TIME ZONE 'America/New_York') AS ny_hour,
  EXTRACT(DATE FROM TIMESTAMP '2026-11-23 03:30:00+00' AT TIME ZONE 'America/New_York') AS ny_date,
  EXTRACT(DAYOFWEEK FROM TIMESTAMP '2026-11-23 03:30:00+00' AT TIME ZONE 'America/New_York') AS ny_day_of_week;
Result
utc_hourny_hourny_dateny_day_of_week
3222026-11-221

DATETIME and TIME inputs

SELECT
  EXTRACT(DATE FROM DATETIME '2026-11-23 18:45:30') AS the_date,
  EXTRACT(TIME FROM DATETIME '2026-11-23 18:45:30') AS the_time,
  EXTRACT(MINUTE FROM TIME '18:45:30') AS minute;
Result
the_datethe_timeminute
2026-11-2318:45:3045

Common mistakes

  • Assuming DAYOFWEEK starts on Monday. BigQuery returns 1 for Sunday and 7 for Saturday. For Monday = 1 use FORMAT_DATE('%u', d), or MOD(EXTRACT(DAYOFWEEK FROM d) + 5, 7) + 1.
  • Pairing ISOWEEK with YEAR. December 29, 2025 is ISO week 1 of 2026; label it with EXTRACT(ISOYEAR ...) or FORMAT_DATE('%G-W%V', d), not with YEAR.
  • Reading a TIMESTAMP in UTC by accident. Without AT TIME ZONE, EXTRACT(HOUR FROM ts) is the UTC hour, which shifts an "orders by hour" chart by your UTC offset.
  • Using PostgreSQL names. EXTRACT(DOW FROM d), EXTRACT(EPOCH FROM ts) and DATE_PART('month', d) don't exist in BigQuery; use DAYOFWEEK, UNIX_SECONDS and EXTRACT(MONTH FROM d).
  • Grouping a multi-year series by EXTRACT(MONTH ...). November 2025 and November 2026 land in the same group; use DATE_TRUNC for time series.

Cost and performance

  • On a partitioned table, EXTRACT(YEAR FROM partition_col) = 2026 (and EXTRACT(DATE FROM ts)) still prune partitions, but other parts such as MONTH or HOUR force a scan of every partition. Filter with a date range and use EXTRACT in SELECT or GROUP BY.

FAQ

How do I get the day of the week in BigQuery?

EXTRACT(DAYOFWEEK FROM d) returns 1 for Sunday to 7 for Saturday. FORMAT_DATE('%A', d) returns the name, such as Monday.

What is the difference between WEEK and ISOWEEK in EXTRACT?

WEEK counts Sunday-based weeks from 0, with days before the first Sunday in week 0. ISOWEEK uses ISO 8601 Monday weeks numbered from 1, where week 1 contains the year's first Thursday.

How do I extract the hour of a timestamp in my time zone?

EXTRACT(HOUR FROM ts AT TIME ZONE 'Asia/Singapore'). Without AT TIME ZONE the hour is in UTC.

How do I get the epoch seconds of a timestamp?

BigQuery has no EXTRACT(EPOCH ...). Use UNIX_SECONDS(ts) or UNIX_MILLIS(ts).

Errors you may hit

More date functions

All BigQuery date 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.