Re: generate_series() Interpretation

From: Michael Nolan <htfoot(at)gmail(dot)com>
To: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
Cc: Steve Crawford <scrawford(at)pinpointresearch(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: generate_series() Interpretation
Date: 2011-06-27 19:12:48
Message-ID: BANLkTi=y6jPhB506r2YvKwb7UBYgnCuw8A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 27, 2011 at 1:38 PM, David E. Wheeler <david(at)kineticode(dot)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(at)tssi(dot)com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Steve Crawford 2011-06-27 19:20:49 Re: generate_series() Interpretation
Previous Message Noah Misch 2011-06-27 18:59:37 Re: [v9.2] DROP Reworks Part.0 - 'missing_ok' support of get_object_address