I'm trying to generate a series in PostgreSQL with the generate_series function. I need a series of months starting from Jan 2008 until current month + 12
(a year out). I'm using and restricted to PostgreSQL 8.3.14 (so I don't have the timestamp series options in 8.4).
I know how to get a series of days like:
select generate_series(0,365) + date '2008-01-01'
But I am not sure how to do months.
SELECT to_char(DATE '2008-01-01' + (interval '1 month' * generate_series(0,56)), 'Mon-YY') AS months
The question is now, how to calculate 56 instead of statically defining it in the query above. 56 is the number of months since Jan 2008 + 12. – Caudle