This is an English translation of a Japanese blog. Some content may not be fully translated.
PostgreSQL

Getting First Day of Month, Last Day of Month, and First Day of Next Month in PostgreSQL

Notes.

select date(date_trunc('month',current_date)); -- First day of month
select date(date_trunc('month',current_date) + ' 1 month' + '-1 Day'); -- Last day of month
select date(date_trunc('month',current_date) + ' 1 month'); -- First day of next month
postgres=# select date(date_trunc('month',current_date)); -- First day of month
    date
------------
 2022-10-01
(1 row)

postgres=# select date(date_trunc('month',current_date) + ' 1 month' + '-1 Day'); -- Last day of month
    date
------------
 2022-10-31
(1 row)

postgres=# select date(date_trunc('month',current_date) + ' 1 month'); -- First day of next month
    date
------------
 2022-11-01
(1 row)
Suggest an edit on GitHub