"David E. Wheeler" <da...@kineticode.com> wrote:
 
> generate_series   
> ---------------------
>  2011-05-31 00:00:00
>  2011-06-30 00:00:00
>  2011-07-31 00:00:00
>  2011-08-31 00:00:00
>  2011-09-30 00:00:00
>  2011-10-31 00:00:00
>  2011-11-30 00:00:00
>  2011-12-31 00:00:00
>  2012-01-31 00:00:00
>  2012-02-29 00:00:00
>  2012-03-31 00:00:00
> 
> Is there some way to change the interpretation of interval
> calculation like this? Or would I just have to write my own
> function to do it the way I want?
 
It is precisely to support such fancy things that some products
support a more abstract date type which allows 31 days in any month,
and then normalizes to real dates as needed.  The PostgreSQL
developer community has generally not been receptive to such use
cases.  I think you need to iterate through month intervals and add
those to the starting date for now.  If you want to start with the
last day of a month with less than 31 days, you may need to back up
a month or two to find a suitable month and offset your intervals by
the appropriate number of months.
 
I'd bet that if you encapsulate all that in a PostgreSQL function,
you're not the only one who would find it useful.
 
-Kevin

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to