From: | Kretschmer Andreas <andreas_kretschmer(at)despammed(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Interval fields |
Date: | 2005-09-30 17:38:02 |
Message-ID: | 20050930173802.GA2307@kaufbach.delug.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
A Gilmore <agilmore(at)shaw(dot)ca> schrieb:
> Hello,
>
> If I have an interval of say '1 day 3 hours 30 minutes' how might I express
> that form of a specified interval type, ie for hours : '27.3 hours'.
>
> Is the only option to write a function that takes an interval and returns
> text in that format?
A 'intervall' can also be something like this:
,----[ how many hours has a month? ]
| test=> select age(t2,t1) from foo2;
| age
| -------------------------
| 8 mons 29 days 19:00:00
`----
I think, it is better to ask:
,----
| test=> select extract(epoch from t2) - extract(epoch from t1) from foo2;
| ?column?
| ----------
| 23565600
`----
Now you can also ask:
,----
| test=> select (extract(epoch from t2) - extract(epoch from t1)) / 3600::float as hours from foo2;
| hours
| -------
| 6546
`----
Regards, Andreas
--
Diese Message wurde erstellt mit freundlicher Unterstützung eines freilau-
fenden Pinguins aus artgerechter Freilandhaltung. Er ist garantiert frei
von Micro$oft'schen Viren. (#97922 http://counter.li.org) GPG 7F4584DA
Was, Sie wissen nicht, wo Kaufbach ist? Hier: N 51.05082°, E 13.56889° ;-)
From | Date | Subject | |
---|---|---|---|
Next Message | Walker, Jed S | 2005-09-30 20:47:37 | Transaction within plpgsql |
Previous Message | Terry Lee Tucker | 2005-09-30 17:36:43 | Re: How to get tabloid |