Create list with first and last day of month for given period

前端 未结 2 409
谎友^
谎友^ 2021-01-19 10:46

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

2条回答
  •  无人及你
    2021-01-19 11:20

    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
    

提交回复
热议问题