FirebirdSQL logo

LAST_DAY()

Returns the last day of a time period containing a datetime value

Result Type

DATE, TIMESTAMP (with or without time zone)

Syntax
LAST_DAY(OF <period> FROM date_or_timestamp)

<period> ::= YEAR | MONTH | QUARTER | WEEK
Table 1. LAST_DAY Function Parameters
Parameter Description

date_or_timestamp

Expression of type DATE, TIMESTAMP WITHOUT TIME ZONE or TIMESTAMP WITH TIME ZONE

LAST_DAY returns a date or timestamp (same as the type of date_or_timestamp) with the last day of the year, month or week of a given date or timestamp value.

Note
  • The last day of the week is considered as Saturday, following the same rules as for [fblangref50-scalarfuncs-extract] with WEEKDAY.

  • When a timestamp is passed, the return value preserves the time part.

Examples of LAST_DAY

select
  last_day(of month from current_date),
  last_day(of year from current_timestamp),
  last_day(of week from date '2017-11-01'),
  last_day(of quarter from date '2017-11-01')
from rdb$database;