From: Ryan Kelly <rpkelly22@gmail.com>
To: afonit@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #7797: datetime + '1 month'::interval is going outside of a month's bounds
Date: Mon, 7 Jan 2013 12:19:15 -0500
Message-ID: <20130107171915.GA18868@llserver.lakeliving.com> (raw)
In-Reply-To: <E1TsDhv-00040y-0S@wrigleys.postgresql.org>
References: <E1TsDhv-00040y-0S@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On Mon, Jan 01/07/13, 2013 at 02:29:43PM +0000, afonit@gmail.com wrote:
> The following bug has been logged on the website:
>
> Bug reference: 7797
> Logged by: Jared Thompson
> Email address: afonit@gmail.com
> PostgreSQL version: 9.2.2
> Operating system: Ubuntu 12.04
> Description:
>
> 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.
February has 29 days in 2012.
>
> 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
> 2012-01-28
>
> and if we added one month to 2012-01-25 we do get 2012-02-25.
>
> It appears that the +'1 month'::interval is making it the next month and
> same date - but if there aren't the same number of days in the months it
> seems to be breaking as noted in the first example.
>
> Again, not sure what the expected behavior is but I would think that 'last
> day of a month' + '1 month'::interval would give 'last day of next month'.
>
> I realize on January 29-30th I am not sure what the expected behavior should
> be.
>
'1 month'::interval is the same as '30 days'::interval.
-Ryan Kelly
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: rpkelly22@gmail.com, afonit@gmail.com
Subject: Re: BUG #7797: datetime + '1 month'::interval is going outside of a month's bounds
In-Reply-To: <20130107171915.GA18868@llserver.lakeliving.com>
References: <E1TsDhv-00040y-0S@wrigleys.postgresql.org> <20130107171915.GA18868@llserver.lakeliving.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox