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: afonit(at)gmail(dot)com
Cc: 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 17:58:40
Message-ID: 13279.1357581520@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

afonit(at)gmail(dot)com writes:
> This query:
> select
> '2012-01-31'::date + '1 month'::interval

> Produces this result:
> "2012-02-29 00:00:00"

> 2012-02-29 is not a valid date. February only goes to 28 days.

Uh, 2012 was a leap year, and so 2012-02-29 is a perfectly valid date.

> I am not sure what the expected behavior should be, but what I was expecting
> is (in the above instance):
> Adding one month to 2012-01-31 would yield the last day of February

It did.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2013-01-07 18:06:55 Re: BUG #7797: datetime + '1 month'::interval is going outside of a month's bounds
Previous Message Tam Tran 2013-01-07 17:54:44 Re: BUG #7797: datetime + '1 month'::interval is going outside of a month's bounds