Request a demo

BigQuery · Date function

BigQuery PARSE_DATE

PARSE_DATE(format_string, string) converts a STRING to a DATE using % elements, such as PARSE_DATE('%d/%m/%Y', '23/11/2026'). Use SAFE.PARSE_DATE to get NULL instead of a query failure for values that don't match.

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

PARSE_DATE reads a date written in any layout. The format string describes the input with the same elements as FORMAT_DATE: %Y year, %m month, %d day, %b or %B month name, and so on. For the canonical YYYY-MM-DD layout, CAST(s AS DATE) is enough.

The whole string must match the format. A value such as '2026-11-23 10:00:00' fails against '%Y-%m-%d' with Failed to parse input string, and a different separator fails with "Mismatch between format character". Day and month numbers may have one or two digits, month and day names are case-insensitive, and leading or trailing spaces are allowed. Fields missing from the format default to 1970-01-01, so '%Y-%m' returns the first of the month.

One bad row fails the whole query. On raw data, use SAFE.PARSE_DATE, which returns NULL for anything it can't parse, and chain several formats with COALESCE when a column mixes layouts.

Syntax

PARSE_DATE(format_string, date_string)

Arguments and return value

ArgumentDescription
format_stringA STRING of format elements that describes date_string, for example '%m/%d/%Y'.
date_stringThe STRING to parse. NULL returns NULL.

Returns: DATE

Examples

Parse common layouts

SELECT
  PARSE_DATE('%m/%d/%Y', '11/23/2026') AS us_style,
  PARSE_DATE('%d.%m.%Y', '23.11.2026') AS german_style,
  PARSE_DATE('%Y%m%d', '20261123') AS compact,
  PARSE_DATE('%b %d, %Y', 'Nov 23, 2026') AS with_month_name;
Result
us_stylegerman_stylecompactwith_month_name
2026-11-232026-11-232026-11-232026-11-23

Dirty input: SAFE.PARSE_DATE returns NULL

Single-digit months and days parse fine. Without SAFE, row 2 would fail the query.

WITH raw AS (
  SELECT 1 AS row_id, '2026-11-23' AS signup UNION ALL
  SELECT 2, '2026/11/23' UNION ALL
  SELECT 3, '' UNION ALL
  SELECT 4, '2026-1-5'
)
SELECT row_id, SAFE.PARSE_DATE('%Y-%m-%d', signup) AS signup_date
FROM raw
ORDER BY row_id;
Result
row_idsignup_date
12026-11-23
2NULL
3NULL
42026-01-05

Missing fields default to January 1

SELECT
  PARSE_DATE('%Y-%m', '2026-11') AS from_year_month,
  PARSE_DATE('%Y', '2026') AS from_year;
Result
from_year_monthfrom_year
2026-11-012026-01-01

A column with several layouts

Put the most specific format first. Ambiguous values such as 03/04/2026 still need a business rule to decide day-first or month-first.

WITH raw AS (
  SELECT 1 AS row_id, '2026-11-23' AS d UNION ALL
  SELECT 2, '23/11/2026' UNION ALL
  SELECT 3, '20261123'
)
SELECT
  row_id,
  COALESCE(
    SAFE.PARSE_DATE('%Y-%m-%d', d),
    SAFE.PARSE_DATE('%d/%m/%Y', d),
    SAFE.PARSE_DATE('%Y%m%d', d)
  ) AS parsed
FROM raw
ORDER BY row_id;
Result
row_idparsed
12026-11-23
22026-11-23
32026-11-23

Common mistakes

  • Swapping the arguments. The format string comes first: PARSE_DATE('%d/%m/%Y', s), not PARSE_DATE(s, '%d/%m/%Y').
  • Using TO_DATE(s, 'DD/MM/YYYY') from Snowflake, Oracle or PostgreSQL, or STR_TO_DATE from MySQL. BigQuery has neither; the closest match is CAST(s AS DATE FORMAT 'DD/MM/YYYY') or PARSE_DATE with % elements.
  • Parsing a value that includes a time. '2026-11-23 10:00:00' doesn't match '%Y-%m-%d'; parse it with PARSE_DATETIME and wrap it in DATE, or take LEFT(s, 10) first.
  • Passing an INT64 such as 20261123. There is no matching signature; convert with CAST(n AS STRING) first.
  • Using %M for the month. %M is minutes; the month is %m.

Cost and performance

  • Parsing a STRING date in WHERE on every query costs slots and can't use partition pruning. Parse once while loading or in a staging model, store a DATE column, and partition on it.

FAQ

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

Use CAST('2026-11-23' AS DATE) for YYYY-MM-DD strings and PARSE_DATE(format, s) for anything else, for example PARSE_DATE('%d/%m/%Y', '23/11/2026').

How do I parse a date without failing on bad values?

Prefix the function with SAFE: SAFE.PARSE_DATE('%Y-%m-%d', s) returns NULL for values that don't match instead of failing the query.

Why do I get "Failed to parse input string"?

Part of the string doesn't match the format, often a time suffix, a different separator or an empty string. See Failed to parse input string.

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.