pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: aanisimov@inbox.ru
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #7722: extract(epoch from age(...)) appears to be broken
Date: Mon, 3 Dec 2012 21:17:00 -0500
Message-ID: <20121204021700.GC7675@momjian.us> (raw)
In-Reply-To: <20121203060556.GA4601@alvh.no-ip.org>
References: <E1TfEH5-0004JE-Qt@wrigleys.postgresql.org>
	<20121203060556.GA4601@alvh.no-ip.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On Mon, Dec  3, 2012 at 03:05:57AM -0300, Alvaro Herrera wrote:
> aanisimov@inbox.ru wrote:
> > The following bug has been logged on the website:
> > 
> > Bug reference:      7722
> > Logged by:          Artem Anisimov
> > Email address:      aanisimov@inbox.ru
> > PostgreSQL version: 9.2.1
> > Operating system:   Slackware Linux 14.0/amd64
> > Description:        
> > 
> > The following to queries give the same result (first arguments to age()
> > differ in the day number only, second arguments are identical):
> > 
> > select extract(epoch from age('2012-11-23 16:41:31', '2012-10-23
> > 15:56:10'));
> > 
> > and
> > 
> > select extract(epoch from age('2012-11-22 16:41:31', '2012-10-23
> > 15:56:10'));
> 
> alvherre=# select age('2012-11-22 16:41:31', '2012-10-23 15:56:10');
>        age        
> ------------------
>  30 days 00:45:21
> (1 fila)
> 
> alvherre=# select age('2012-11-23 16:41:31', '2012-10-23 15:56:10');
>       age       
> ----------------
>  1 mon 00:45:21
> (1 fila)
> 
> The problem is that age() returns 30 days in one case, and "one month" in the
> other; extract() then considers the month as equivalent to 30 days.  This is
> documented as such, see [1].
> 
> [1] http://www.postgresql.org/docs/current/static/functions-datetime.html

Wow, that is a weird case.  In the first test, we count the number of
days because it is less than a full month.  In the second case, we call
it a full month, but then forget how long it is.  Not sure how we could
improve this.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +


-- 
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 (9+ messages)  latest in thread

Message-ID: <20121204021700.GC7675@momjian.us>
Permalink:  ../20121204021700.GC7675@momjian.us/
Also on:    postgresql.org/message-id/20121204021700.GC7675@momjian.us

 · 

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: bruce@momjian.us, alvherre@2ndquadrant.com, aanisimov@inbox.ru
  Subject: Re: BUG #7722: extract(epoch from age(...)) appears to be broken
  In-Reply-To: <20121204021700.GC7675@momjian.us>
  References: <E1TfEH5-0004JE-Qt@wrigleys.postgresql.org> <20121203060556.GA4601@alvh.no-ip.org> <20121204021700.GC7675@momjian.us>

* 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