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

From Michael Nolan
Subject Re: generate_series() Interpretation
Date
Msg-id BANLkTi=y6jPhB506r2YvKwb7UBYgnCuw8A@mail.gmail.com
Whole thread Raw
In response to Re: generate_series() Interpretation  ("David E. Wheeler" <david@kineticode.com>)
List pgsql-hackers


On Mon, Jun 27, 2011 at 1:38 PM, David E. Wheeler <david@kineticode.com> wrote:

Yeah, which is why I said it was subject to interpretation. Of course there's no way to tell generate_series() which to use, which is what I figured.

generate_series() is doing exactly what it was designed to do, the imprecision regarding adding '1 month' to something that may or may not have been intended to be 'last day of the month' is a limitation in the interval code.

One way to change this would be to implement another interval type such as 'full_month'  which would take a date that is know to be the last day of the month and make it the last day of the appropriate month.  If the starting date is NOT the last day of a month, the existing logic would suffice. 

Or you can do as I have done and create your own last_day() function that takes any date and makes it the last day of that month, and apply it to the output of generate_series();
--
Mike Nolan
nolan@tssi.com

pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: [v9.2] DROP Reworks Part.0 - 'missing_ok' support of get_object_address
Next
From: Steve Crawford
Date:
Subject: Re: generate_series() Interpretation