Skip to main content
Returns the last day of an input DATE or DATETIME expression based on the specified date part. For example, last_day('2023-05-10', 'month') returns the last day of the month in which ‘2023-05-10’ falls. If the date part is not specified, this function returns the last day of the month for a given date. This function is supported from v3.1.

Syntax

Parameters

  • date_expr: a DATE or DATETIME expression, required.
  • unit: the date part, optional. Valid values include month, quarter, and year, default to month. If unit is invalid, an error is returned.

Return value

Returns a DATE value.

Examples

keyword

LAST_DAY, LAST