Re: BUG #7797: datetime + '1 month'::interval is going outside of a month's bounds

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ryan Kelly <rpkelly22(at)gmail(dot)com>
Cc: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>, afonit(at)gmail(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #7797: datetime + '1 month'::interval is going outside of a month's bounds
Date: 2013-01-07 18:06:55
Message-ID: 13442.1357582015@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Ryan Kelly <rpkelly22(at)gmail(dot)com> writes:
> On Mon, Jan 01/07/13, 2013 at 05:42:40PM +0000, Daniele Varrazzo wrote:
>> On Mon, Jan 7, 2013 at 5:19 PM, Ryan Kelly <rpkelly22(at)gmail(dot)com> wrote:
>>> '1 month'::interval is the same as '30 days'::interval.

>> No, it's not.

> Alright, now I'm thoroughly confused. What magic makes this true:
> # select '30 days'::interval = '1 month'::interval;
> ?column?
> ----------
> t

'1 month' and '30 days' are distinct concepts. Some operations will
treat them as equal, if there is no additional info that will nail
down the actual length of the particular month in question. Or if
you like, 30 days is the "default" length of a month.

A related point is that the interval equality operator will say that
'24 hours' and '1 day' are equal, even though they aren't the same
thing --- there are cases where they behave differently, when working
near a DST transition time.

There might be some use for an interval "identity" operator, which would
only say true for completely-indistinguishable interval values; but we
don't have one.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Rodrigo Rosenfeld Rosas 2013-01-07 18:50:17 wrong search_path being used
Previous Message Tom Lane 2013-01-07 17:58:40 Re: BUG #7797: datetime + '1 month'::interval is going outside of a month's bounds