Re: BUG #7797: datetime + '1 month'::interval is going outside of a month's bounds - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #7797: datetime + '1 month'::interval is going outside of a month's bounds
Date
Msg-id 13279.1357581520@sss.pgh.pa.us
Whole thread Raw
In response to BUG #7797: datetime + '1 month'::interval is going outside of a month's bounds  (afonit@gmail.com)
List pgsql-bugs
afonit@gmail.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

pgsql-bugs by date:

Previous
From: Tam Tran
Date:
Subject: Re: BUG #7797: datetime + '1 month'::interval is going outside of a month's bounds
Next
From: Tom Lane
Date:
Subject: Re: BUG #7797: datetime + '1 month'::interval is going outside of a month's bounds