postgresql last month code example
Example 1: last 6 months postgresql
CURRENT_DATE - INTERVAL '6 months'
Example 2: postgresql get last day of month
create function end_of_month(date)
returns date as
$$
select (date_trunc('month', $1) + interval '1 month' - interval '1 day')::date;
$$ language 'sql'
immutable strict;