Find the first day of the month for a date in the middle of the month:
select date_trunc('month', timestamp '2015-10-21 01:02:03'); rollback;
┌─────────────────────┐
│ date_trunc │
├─────────────────────┤
│ 2015-10-01 00:00:00 │
└─────────────────────┘
Find the last day of the month for a date in the middle of the month:
select date_trunc('month', timestamp '2015-10-21 01:02:03') + interval '1 month -1 day'; rollback;
┌─────────────────────┐
│ ?column? │
├─────────────────────┤
│ 2015-10-31 00:00:00 │
└─────────────────────┘