Skip to content

SQL - PostgreSQL - Get Last Day of Month

Source: https://wiki.postgresql.org/wiki/Date_LastDay

CREATE OR REPLACE FUNCTION last_day(date)
RETURNS date AS
$$
  SELECT (date_trunc('MONTH', $1) + INTERVAL '1 MONTH - 1 day')::date;
$$ LANGUAGE 'sql' IMMUTABLE STRICT;

Note: for PostgreSQL only


Backlinks:

list from [[SQL - Get Last Dat of Month]] AND -"Changelog"