Re: generate_series() Interpretation - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: generate_series() Interpretation
Date
Msg-id 4E087F95020000250003EC64@gw.wicourts.gov
Whole thread Raw
In response to generate_series() Interpretation  ("David E. Wheeler" <david@kineticode.com>)
Responses Re: generate_series() Interpretation
List pgsql-hackers
"David E. Wheeler" <david@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


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [COMMITTERS] pgsql: Make the visibility map crash-safe.
Next
From: Robert Haas
Date:
Subject: Re: pg_upgrade defaulting to port 25432