postgresql - Postgres - Convert Date Range to Individual Month -
i have found similar help, issue more complex, basics of sql , striking out here. handful of columns a,b,c,startdate,enddate , need parse data out multiple rows depending on how many months within range.
eg: a,b,c,1/1/2015, 3/15,2015 become:
a,b,c,1/1/2015,value_here_doesnt_matter a,b,c,2/1/2015,value_here_doesnt_matter a,b,c,3/1/2015,value_here_doesnt_matter
does not matter if start date or end date on specific day, thing matters month , year. if range included day in given month, i'd want output start days each month in range, 1st default day.
could have advice on direction begin? i'm attempting generate_series, unsure if right approach or how make work keeping data in first few arbitrary columns consistent.
i think generate_series
way go. without knowing rest of data looks like, start this:
select a, b, c, generate_series(startdate, enddate, interval '1 month')::date my_table
Comments
Post a Comment