postgresql get last day of month

Solutions on MaxInterview for postgresql get last day of month by the best coders in the world

showing results for - "postgresql get last day of month"
Josefina
30 Sep 2017
1SELECT (date_trunc('month', '2017-01-05'::date) + interval '1 month' - interval '1 day')::date
2AS end_of_month;
3
Domenico
17 May 2019
1create function end_of_month(date)
2returns date as
3$$
4select (date_trunc('month', $1) + interval '1 month' - interval '1 day')::date;
5$$ language 'sql'
6immutable strict;
7