Request a demo

BigQuery · Date function

BigQuery DATE_FROM_UNIX_DATE

DATE_FROM_UNIX_DATE(n) converts a count of days since 1970-01-01 into a DATE: DATE_FROM_UNIX_DATE(20780) is 2026-11-23. Use it for columns that store dates as day numbers, such as Avro date fields read as integers.

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

DATE_FROM_UNIX_DATE is the inverse of UNIX_DATE. It reads an INT64 as days after (or, if negative, before) 1970-01-01 and returns the matching DATE.

Day counts show up in exports from systems that store dates as integers, in Avro and Parquet files where a date column was loaded as INT64, and in hand-built integer keys. The valid input range is -719162 to 2932896, which maps to 0001-01-01 and 9999-12-31.

Don't confuse day counts with epoch seconds or milliseconds. A value like 1795392000 is seconds; DATE_FROM_UNIX_DATE rejects it as out of range. Convert seconds with TIMESTAMP_SECONDS and milliseconds with TIMESTAMP_MILLIS, then take the DATE.

Syntax

DATE_FROM_UNIX_DATE(int64_expression)

Arguments and return value

ArgumentDescription
int64_expressionDays since 1970-01-01, from -719162 to 2932896. NULL returns NULL.

Returns: DATE

Examples

Day numbers to dates

SELECT
  DATE_FROM_UNIX_DATE(20780) AS d,
  DATE_FROM_UNIX_DATE(0) AS epoch,
  DATE_FROM_UNIX_DATE(-1) AS before_epoch;
Result
depochbefore_epoch
2026-11-231970-01-011969-12-31

Decode an integer date column from an export

WITH raw_events AS (
  SELECT 'e1' AS event_id, 20780 AS event_day UNION ALL
  SELECT 'e2', 20787
)
SELECT event_id, DATE_FROM_UNIX_DATE(event_day) AS event_date
FROM raw_events
ORDER BY event_id;
Result
event_idevent_date
e12026-11-23
e22026-11-30

Epoch seconds need TIMESTAMP_SECONDS instead

DATE_FROM_UNIX_DATE(1795392000) fails with "DATE_FROM_UNIX_DATE range is -719162 to 2932896 but saw 1795392000".

SELECT DATE(TIMESTAMP_SECONDS(1795392000)) AS from_seconds;
Result
from_seconds
2026-11-23

Common mistakes

  • Passing epoch seconds or milliseconds. Ten-digit values are seconds and thirteen-digit values are milliseconds; both are out of range for a day count.
  • Passing a STRING or FLOAT64 column. The argument must be INT64; use CAST(col AS INT64) (or SAFE_CAST for dirty data) first.
  • Assuming every integer date is days since 1970. Some systems store YYYYMMDD (20261123) instead; parse those with PARSE_DATE('%Y%m%d', CAST(n AS STRING)).

FAQ

How do I convert days since epoch to a date in BigQuery?

DATE_FROM_UNIX_DATE(days). For example DATE_FROM_UNIX_DATE(20780) returns 2026-11-23.

How do I convert a Unix timestamp to a date?

For seconds use DATE(TIMESTAMP_SECONDS(s)), for milliseconds DATE(TIMESTAMP_MILLIS(ms)). Add a time zone argument to DATE for a local date.

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.