Re: fomatting an interval (resend) - Mailing list pgsql-general

From greg@turnstep.com
Subject Re: fomatting an interval (resend)
Date
Msg-id 3616683024ca631d95ed19e803a6b2fa@biglumber.com
Whole thread Raw
In response to Re: fomatting an interval (resend)  (lyris-pg@tibit.com)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


>>> Okay, so extract() doesn't fit the bill either.  How do I get the
>>> difference between two timestamps in terms of days, expressed as an
>>> integer?  Moreover, how do I get any interval expressed in those
>>> terms?

>> select round((extract(epoch from finish) -
>> extract(epoch from start))/(60*60*24)) from timetable;

>How would that differ from the query below?
>
>select round(extract(epoch from (finish - start))/(60*60*24)) from
>timetable;

No real difference - the first is extracting from timestamps, the
second is extracting from an interval. The second is more compact,
but I prefer the first as it is a little more explicit in what is
happening.

- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200305301433
-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iD8DBQE+16QZvJuQZxSWSsgRAhPyAKC9lz5pAr7W94Sm6MPXp77CoG04UgCg062W
0ylMMu/79liaR48hG3tIw2c=
=zQTl
-----END PGP SIGNATURE-----



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: CURRENT_DATE and CURRENT_TIME return incorrect values
Next
From: "Wayne Armstrong"
Date:
Subject: Re: implicit abort harmful?