Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TsGMB-0008Kh-UN for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Jan 2013 17:19:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TsGMB-0001Bq-81 for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Jan 2013 17:19:27 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TsGM5-00016P-55 for pgsql-bugs@postgresql.org; Mon, 07 Jan 2013 17:19:21 +0000 Received: from mail-ie0-f174.google.com ([209.85.223.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TsGM4-0006Tu-0F for pgsql-bugs@postgresql.org; Mon, 07 Jan 2013 17:19:20 +0000 Received: by mail-ie0-f174.google.com with SMTP id c11so23683095ieb.5 for ; Mon, 07 Jan 2013 09:19:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=4TOSiKhiz4MIxUNAL1q3/vvnGfPWI+N3UtXPkB4/g0c=; b=HV5ZrAi+Ec4ybHtFspizrPCht6q+c790QfTH13DvhFB0YRN1E+8qYtUlnMRXOMpd81 wV9p5mY/T+EfCNQKfDsj9cfJmd8iy849JuzuRujJnRN7o5j99H9hLrrBkl3YzccCMtk0 Q9NK6G0O40yKSU0cAHvY8Dwggx6WUv5HeAxpjvxcIRT6Bj0PPQozhstYMA/haLyPYe8R 0Qb/OfpsYF2UAwBJzaQn67vEthxKgN7bNMCJpmqi9twxXyhF6sGkOKAhn1Sn8iDXIFXM vATo5/v0DNO9/+1PJ/l2Peo7r2m1lgoWq8JHEx2jROUHIHacar/siA5AciciXm13PNkm ayIg== X-Received: by 10.50.196.198 with SMTP id io6mr6221598igc.39.1357579159497; Mon, 07 Jan 2013 09:19:19 -0800 (PST) Received: from llserver.lakeliving.com (ool-18bbd2c6.static.optonline.net. [24.187.210.198]) by mx.google.com with ESMTPS id rd10sm7348350igb.1.2013.01.07.09.19.18 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 07 Jan 2013 09:19:18 -0800 (PST) Date: Mon, 7 Jan 2013 12:19:15 -0500 From: Ryan Kelly 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 Message-ID: <20130107171915.GA18868@llserver.lakeliving.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.3 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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