I have to generate a list with two columns of day intervals for every month in a specific period. First column must be the first day of month and the second column the last
Based on this answer:
select d::date as start_date,(d + '1 month'::interval - '1 day'::interval )::date end_date
from generate_series('2014-01-01'::date, '2014-06-30'::date, '1 month'::interval) d
Add a month and subtract a day - in a single interval expression:
SELECT d AS mon_first
, d + interval '1 month - 1 day' AS mon_last
FROM generate_series(timestamp '2014-01-01'
, timestamp '2014-06-30'
, interval '1 month') d;
Further reading ("end of day" is very similar to "last day of month"):
About generating a time series: