pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: mmerta <michal.merta@greycortex.com>
To: pgsql-bugs@postgresql.org
Subject: Wrong results of function age(timestamp, timestamp)
Date: Wed, 5 Oct 2016 07:01:02 -0700 (MST)
Message-ID: <1475676061981-5924559.post@n3.nabble.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Hello,

I ecountered strange behaviour of function age(timestamp, timestamp). 

Let's say we have two timestamps and we want to compute their age() from
fixed timestamp in past:


SELECT pg_catalog.age('2016-04-30 00:00:01'::TIMESTAMP , '2015-01-01
12:00:00'::TIMESTAMP),
       pg_catalog.age('2016-04-29 23:59:59'::TIMESTAMP , '2015-01-01
12:00:00'::TIMESTAMP);

              age               |              age               
--------------------------------+--------------------------------
 1 year 3 mons 28 days 12:00:01 | 1 year 3 mons 28 days 11:59:59


Results are correct. 

If we add '1 day'::interval to original timestamps, both results should be 1
day longer. 
Howewer first result is exactly 24 hours longer than it should be:



SELECT pg_catalog.age(('2016-04-30 00:00:01'::TIMESTAMP + '1
day'::INTERVAL), '2015-01-01 12:00:00'::TIMESTAMP),
       pg_catalog.age(('2016-04-29 23:59:59'::TIMESTAMP + '1
day'::INTERVAL), '2015-01-01 12:00:00'::TIMESTAMP);
              age               |              age               
--------------------------------+--------------------------------
 1 year 3 mons 30 days 12:00:01 | 1 year 3 mons 29 days 11:59:59


Am I missing something or is it a bug in function age(timestamp, timestamp)?


I tested this on postgres versions 9.4.6 and 9.5.3 on CentOS 7, using
timezone = 'Europe/Prague' in postgresql.conf.



Regards
Michal Merta



--
View this message in context: http://postgresql.nabble.com/Wrong-results-of-function-age-timestamp-timestamp-tp5924559.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)  latest in thread

Message-ID: <1475676061981-5924559.post@n3.nabble.com>
Permalink:  ../1475676061981-5924559.post@n3.nabble.com/
Also on:    postgresql.org/message-id/1475676061981-5924559.post@n3.nabble.com

 · 

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: michal.merta@greycortex.com
  Subject: Re: Wrong results of function age(timestamp, timestamp)
  In-Reply-To: <1475676061981-5924559.post@n3.nabble.com>
  References: <1475676061981-5924559.post@n3.nabble.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