Request a demo

BigQuery · Date function

BigQuery LAST_DAY

LAST_DAY(date) returns the last day of the month that contains a date, such as 2026-11-30 for 2026-11-23. Pass QUARTER, YEAR, WEEK, ISOWEEK or ISOYEAR as a second argument for the last day of other periods.

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

LAST_DAY returns the final DATE of the period that contains the input. Without a second argument the period is MONTH, which covers the common question "what is the end of this month". Leap years are handled: LAST_DAY(DATE '2028-02-10') is February 29.

Other periods: QUARTER and YEAR return the quarter and year end. WEEK weeks start on Sunday, so the last day is a Saturday; WEEK(MONDAY) and ISOWEEK end on Sunday. ISOYEAR returns the Sunday before the next ISO year starts, which can fall in early January.

LAST_DAY also accepts a DATETIME and still returns a DATE. Pair it with DATE_TRUNC for the first day of the same period.

Syntax

LAST_DAY(date_expression[, date_part])

Arguments and return value

ArgumentDescription
date_expressionA DATE (or DATETIME). NULL returns NULL.
date_partOptional, unquoted: MONTH (default), QUARTER, YEAR, WEEK, WEEK(<WEEKDAY>), ISOWEEK or ISOYEAR.

Returns: DATE

Examples

End of the month, quarter and year

SELECT
  LAST_DAY(DATE '2026-11-23') AS month_end,
  LAST_DAY(DATE '2026-11-23', QUARTER) AS quarter_end,
  LAST_DAY(DATE '2026-11-23', YEAR) AS year_end,
  LAST_DAY(DATE '2028-02-10') AS leap_february_end;
Result
month_endquarter_endyear_endleap_february_end
2026-11-302026-12-312026-12-312028-02-29

End of the week and the ISO year

ISO year 2027 starts on Monday, January 4, 2027, so ISO year 2026 ends on Sunday, January 3.

SELECT
  LAST_DAY(DATE '2026-11-23', WEEK) AS sunday_week_end,
  LAST_DAY(DATE '2026-11-23', WEEK(MONDAY)) AS monday_week_end,
  LAST_DAY(DATE '2026-11-23', ISOWEEK) AS iso_week_end,
  LAST_DAY(DATE '2026-11-23', ISOYEAR) AS iso_year_end;
Result
sunday_week_endmonday_week_endiso_week_endiso_year_end
2026-11-282026-11-292026-11-292027-01-03

Days left in the month and a month-end flag

WITH payments AS (
  SELECT 'p1' AS payment_id, DATE '2026-11-23' AS paid_on UNION ALL
  SELECT 'p2', DATE '2026-11-30' UNION ALL
  SELECT 'p3', DATE '2026-02-28'
)
SELECT
  payment_id,
  DATE_DIFF(LAST_DAY(paid_on), paid_on, DAY) AS days_left_in_month,
  paid_on = LAST_DAY(paid_on) AS is_month_end
FROM payments
ORDER BY payment_id;
Result
payment_iddays_left_in_monthis_month_end
p17false
p20true
p30true

DATETIME input returns a DATE

SELECT LAST_DAY(DATETIME '2026-11-23 18:45:00') AS month_end;
Result
month_end
2026-11-30

Common mistakes

  • Computing month ends by hand. DATE_SUB(DATE_ADD(DATE_TRUNC(d, MONTH), INTERVAL 1 MONTH), INTERVAL 1 DAY) works but is easy to get wrong; LAST_DAY(d) is the same thing.
  • Expecting LAST_DAY(d, WEEK) to be a Sunday. WEEK starts on Sunday, so it ends on Saturday. Use WEEK(MONDAY) or ISOWEEK for Sunday week ends.
  • Using a month end as an exclusive upper bound on a TIMESTAMP or DATETIME column. ts <= LAST_DAY(d) stops at midnight on the last day and misses that whole day; use ts < DATE_ADD(LAST_DAY(d), INTERVAL 1 DAY) or the first day of the next month.
  • Porting EOMONTH(d) from SQL Server or Excel, or Snowflake's LAST_DAY(d, 'month') with a quoted part. In BigQuery the part is an unquoted keyword.

FAQ

How do I get the last day of the month in BigQuery?

LAST_DAY(d) or LAST_DAY(d, MONTH). For the current month: LAST_DAY(CURRENT_DATE()).

How do I get the last day of the previous month?

LAST_DAY(DATE_SUB(d, INTERVAL 1 MONTH)), or DATE_TRUNC(d, MONTH) - 1.

Does LAST_DAY handle leap years?

Yes. LAST_DAY(DATE '2028-02-10') returns 2028-02-29 and LAST_DAY(DATE '2026-02-10') returns 2026-02-28.

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.