Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bgyBh-0006mg-NI for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Sep 2016 18:00:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bgyBh-0003Vk-5M for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Sep 2016 18:00:05 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bgyBg-0003Va-Kg for pgsql-bugs@postgresql.org; Mon, 05 Sep 2016 18:00:04 +0000 Received: from fr1.2ndquadrant.fr ([2001:41d0:2:127c::1]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bgyBd-0004US-AU for pgsql-bugs@postgresql.org; Mon, 05 Sep 2016 18:00:03 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by fr1.2ndquadrant.fr (Postfix) with ESMTP id 0759B5FC9B; Mon, 5 Sep 2016 19:59:59 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at fr1.2ndquadrant.fr Received: from fr1.2ndquadrant.fr ([127.0.0.1]) by localhost (fr1.2ndquadrant.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bZPjBRclXgv9; Mon, 5 Sep 2016 19:59:57 +0200 (CEST) Received: from [192.168.0.3] (ath91-3-88-167-161-184.fbx.proxad.net [88.167.161.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: charles) by fr1.2ndquadrant.fr (Postfix) with ESMTPSA id A99E25FC08; Mon, 5 Sep 2016 19:59:57 +0200 (CEST) Subject: Re: BUG #14313: justify interval bug To: coolman.peto@centrum.cz, pgsql-bugs@postgresql.org References: <20160905163158.1413.60004@wrigleys.postgresql.org> From: Vik Fearing Message-ID: Date: Mon, 5 Sep 2016 19:59:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160905163158.1413.60004@wrigleys.postgresql.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -3.6 (---) 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 09/05/2016 06:31 PM, coolman.peto@centrum.cz wrote: > The following bug has been logged on the website: > > Bug reference: 14313 > Logged by: Peter Peterkys > Email address: coolman.peto@centrum.cz > PostgreSQL version: 9.3.14 > Operating system: Ubuntu 14.04 LTS > Description: > > The function "justify_interval" does not work properly. > E.g. if I subtract two different dates with the same month and with the same > day, but with different year, then I got greater interval than I should > get. > Please see my example > > select justify_interval('2016-09-01'::timestamp - '1996-09-01') as test; > > I got result: > '20 years 3 mons 15 days' > > How is it possible? Your timestamp subtraction results in 7305 days. The justify_interval function, not knowing anything about where those days came from, will use 30 days per month, giving you the result you see. > I should got the result: > '20 years' right? Perhaps you want the age() function? =# select age('2016-09-01'::timestamp, '1996-09-01'); age ---------- 20 years (1 row) -- Vik Fearing +33 6 46 75 15 36 http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs