LAST_DAY function in BigQuery

The LAST_DAY function in BigQuery returns the last day of a specified date period (such as a month, quarter, or year) based on a given DATE expression.

SQL Syntax

LAST_DAY(date_expression[, date_part])    

We can optionally specify the date_part for which the last day is returned. If this parameter is not provided, the default value is MONTH.

Supported date_part Values

date_partMeaning
MONTHLast day of the month (default)
QUARTERLast day of the quarter
YEARLast day of the year

Example: Last Day of the Month (Default Behavior)

SQL

SELECT LAST_DAY(DATE(2025, 06, 20), MONTH) AS last_day;    

Output: 2025-06-30

Explanation

Example: Last Day of the Year

SQL

SELECT LAST_DAY(DATE(2025, 06, 20), YEAR) AS last_day;    

Output: 2025-12-31

Explanation

Example: Last Day of the Quarter

SQL

SELECT
  LAST_DAY(DATE(2025, 06, 20), QUARTER) AS last_day;    

Output: 2025-06-30

Explanation