Re: fomatting an interval (resend)

From: greg(at)turnstep(dot)com
To: pgsql-general(at)postgresql(dot)org
Subject: Re: fomatting an interval (resend)
Date: 2003-05-30 18:37:06
Message-ID: 3616683024ca631d95ed19e803a6b2fa@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers


-----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(at)turnstep(dot)com
PGP Key: 0x14964AC8 200305301433
-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Wayne Armstrong 2003-05-30 18:43:41 Re: implicit abort harmful?
Previous Message Tom Lane 2003-05-30 17:53:43 Re: CURRENT_DATE and CURRENT_TIME return incorrect values

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruno Wolff III 2003-05-30 19:03:17 Re: index suggestion for 7.4
Previous Message Stephan Szabo 2003-05-30 18:31:23 Re: index suggestion for 7.4