pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peterko <coolman.peto@centrum.cz>
To: Vik Fearing <vik@2ndquadrant.fr>
To: pgsql-bugs@postgresql.org
Subject: Re: [BUGS] BUG #14313: justify interval bug
Date: Mon, 05 Sep 2016 20:54:56 +0200
Message-ID: <20160905205456.C8D85C34@centrum.cz> (raw)
References: <20160905163158.1413.60004@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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 <http://2ndQuadrant.fr;     PostgreSQL : Expertise, Formation et Support

view thread (5+ messages)  latest in thread

Message-ID: <20160905205456.C8D85C34@centrum.cz>
Permalink:  ../20160905205456.C8D85C34@centrum.cz/
Also on:    postgresql.org/message-id/20160905205456.C8D85C34@centrum.cz

 · 

reply

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: coolman.peto@centrum.cz, vik@2ndquadrant.fr
  Subject: Re: [BUGS] BUG #14313: justify interval bug
  In-Reply-To: <20160905205456.C8D85C34@centrum.cz>
  References: <20160905163158.1413.60004@wrigleys.postgresql.org> <20160905205456.C8D85C34@centrum.cz>

* 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