LAST_DAY

Syntax

LAST_DAY
(
  value  IN date
)
RETURNS date;

LAST_DAY
(
  value  IN TIMESTAMP with time zone
)
RETURNS TIMESTAMP without time zone;

Overview

The LAST_DAY function returns the last day of the month to which the given date belongs.

For the DATE type, it simply calculates the last day of the month.

For the TIMESTAMPTZ type, the date is truncated and the original time information is combined to return a timestamp value.

Parameters

Parameter
Description

value

date, timestamptz type: the base date to get the last date from. For timestamptz, it is calculated by finding the first day of the month, adding one month and subtracting one day.

Example

-- DATE type example: returns the last day of month that '2023-05-15'belongs to
SELECT oracle.LAST_DAY('2023-05-15'::date);
-- result: '2023-05-31' (the last day of May,2023)

  last_day  
------------
 2023-05-31
(1 row)

-- TIMESTAMPTZ type example: return the last day of month that '2023-05-15 14:30:00+09'belongs to
SELECT oracle.LAST_DAY('2023-05-15 14:30:00+09'::timestamptz);
-- result: The timestamp value is returned with the last day of the month combined with the original time information.

      last_day       
---------------------
 2023-05-31 14:30:00
(1 row)

Last updated