From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | "Francisco Olarte (M)" <folarte(at)peoplecall(dot)com> |
Cc: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, aanisimov(at)inbox(dot)ru, PostgreSQL-documentation <pgsql-docs(at)postgresql(dot)org> |
Subject: | Re: [BUGS] BUG #7722: extract(epoch from age(...)) appears to be broken |
Date: | 2013-08-24 01:36:58 |
Message-ID: | 20130824013658.GA3412@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-docs |
I have developed the attached doc patch to address your very clear
illustration that our documentation is lacking in this area.
---------------------------------------------------------------------------
On Tue, Dec 4, 2012 at 08:18:31PM +0100, Francisco Olarte (M) wrote:
> > 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.
>
> I do not think this needs to be improved, the problem is given two
> dates you can substract them in three different ways,
>
> 1.- (year months)+(days)+(hours minutes seconds), which is what age
> does and is documented as such.
>
> folarte=# select age('2013-11-24 16:41:31','2012-10-23 15:56:10');
> age
> -----------------------------
> 1 year 1 mon 1 day 00:45:21
> (1 row)
>
> Which is apropiate for things like 'I'm xxx old'
>
> 2.- (days)+(hours-minutes-seconds), which is what substractint dates
> do ( or seems to do for me, as I've done:
>
> select timestamp '2013-11-23 16:41:31' - '2012-10-23 15:56:10';
> ?column?
> -------------------
> 396 days 00:45:21
>
> Which I can not find a use for, but there sure are and I'm doomed to
> find one soon.
>
> 3.- Exact duration ( I do this a lot at work as I need to calculate
> call durations ):
>
> folarte=# select extract(epoch from timestamp '2013-11-23 16:41:31') -
> extract(epoch from timestamp '2012-10-23 15:56:10');
> ?column?
> ----------
> 34217121
> (1 row)
>
> folarte=# select (extract(epoch from timestamp '2013-11-23 16:41:31')
> - extract(epoch from timestamp '2012-10-23 15:56:10')) * interval '1
> second';
> ?column?
> ------------
> 9504:45:21
> (1 row)
>
> The problem I see is intervals are really complicated and difficult to
> undestand, so it is at most a documentation problem ( people usually
> understimate the difficulty of working with them, I see this a lot at
> work ).
>
> Francisco Olarte.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
Attachment | Content-Type | Size |
---|---|---|
dates.diff | text/x-diff | 3.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Jaime Casanova | 2013-08-24 06:14:28 | Re: BUG #8394: SQL command REINDEX doesn't work |
Previous Message | Bruce Momjian | 2013-08-23 22:13:26 | Re: BUG #7652: Documentation index lacks functions from "Additional Supplied Modules" |
From | Date | Subject | |
---|---|---|---|
Next Message | Ian Lawrence Barwick | 2013-08-27 04:31:45 | 9.3: mention checksum feature in "29.1. Reliability" |
Previous Message | Bruce Momjian | 2013-08-23 22:13:26 | Re: BUG #7652: Documentation index lacks functions from "Additional Supplied Modules" |