Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bgzKj-0001BQ-Fj for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Sep 2016 19:13:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bgzKi-0007TN-69 for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Sep 2016 19:13:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bgz2t-0005xY-Ns for pgsql-bugs@postgresql.org; Mon, 05 Sep 2016 18:55:03 +0000 Received: from gmmr2.centrum.cz ([2a00:da80:1:502::2]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bgz2p-00021s-Hn for pgsql-bugs@postgresql.org; Mon, 05 Sep 2016 18:55:02 +0000 Received: from mail1009.cent (unknown [10.255.254.13]) by gmmr2.centrum.cz (Postfix) with ESMTP id CF89B60012D6; Mon, 5 Sep 2016 20:54:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=centrum.cz; s=mail; t=1473101696; bh=+0qCkXbqLWeaq8w1Var4gJuRp4gV5noos6ZdfSdm7Ms=; h=To:Subject:Date:From:References:In-Reply-To:From; b=C7GufmcbeGjZh7IsAV7l2ZQAcdH6Z5g79Q1YrnRzgCDA4imMfxuwTnJT8OPb1XNgJ DOn2x3+moDGXq13FHj/OxM17EMxUpB7FXSYkdbunIIhdQ4vaWX1MpMKK5QK2lXPmFF 0iMmJpYxVSTGNgSfXwkqNhJnOopyE7GfrJCFMjYs= Received: by mail1009.cent (Postfix, from userid 33) id C83C9D09E07; Mon, 5 Sep 2016 20:54:56 +0200 (CEST) To: =?utf-8?q?Vik_Fearing?= , Subject: =?utf-8?q?Re=3A_=5BBUGS=5D_BUG_=2314313=3A_justify_interval_bug?= Received: from 86.49.75.134 (X-Forwarded-For: 86.49.75.134) by mail1009.centrum.cz (centrum.cz multimail) with HTTP Date: Mon, 05 Sep 2016 20:54:56 +0200 From: "Peterko" References: <20160905163158.1413.60004@wrigleys.postgresql.org> 0000000054f70018bfe40330db75 In-Reply-To: 0000000054f70018bfe40330db75 X-Mailer: Centrum Email 5.3 X-Priority: 3 X-Original-From: coolman.peto@centrum.cz MIME-Version: 1.0 Message-Id: <20160905205456.C8D85C34@centrum.cz> X-Pg-Spam-Score: -3.8 (---) Content-Type: multipart/alternative; boundary="_d32c_-------cf0ba8b97e454b69bfcdd59691716aca" 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 This is a multi-part message in MIME format. --_ca29_-------9e3593e50481ad8e1d5327b041cae749 Content-Type: multipart/alternative; boundary="_d32c_-------cf0ba8b97e454b69bfcdd59691716aca" --_d32c_-------cf0ba8b97e454b69bfcdd59691716aca Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, thanks for your response.   Does it mean that if I use some timestamp and I add interval '20 years', it will be fine, but only if I try to use "justify interval" function, the inconsistency occur? Now I understand the limits for using the function justify_interval ...   Best regards Peter   ______________________________________________________________ > Od: Vik Fearing > Komu: coolman.peto@centrum.cz, pgsql-bugs@postgresql.org > Datum: 05.09.2016 19:59 > Předmět: Re: [BUGS] BUG #14313: justify interval bug > 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 --_d32c_-------cf0ba8b97e454b69bfcdd59691716aca Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi,
thanks for your response.
 

Does it mean that if I use some timestamp and I add interval '20 years', it will be fine, but only if I try to use "justify interval" function, the inconsistency occur?

Now I understand the limits for using the function justify_interval ...

 

Best regards

Peter

 

______________________________________________________________
> Od: Vik Fearing <vik@2ndquadrant.fr>
> Komu: coolman.peto@centrum.cz, pgsql-bugs@postgresql.org
> Datum: 05.09.2016 19:59
> Předmět: Re: [BUGS] BUG #14313: justify interval bug
>

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
--_d32c_-------cf0ba8b97e454b69bfcdd59691716aca-- --_ca29_-------9e3593e50481ad8e1d5327b041cae749--