Re: Interval fields - Mailing list pgsql-novice

From Kretschmer Andreas
Subject Re: Interval fields
Date
Msg-id 20050930173802.GA2307@kaufbach.delug.de
Whole thread Raw
In response to Interval fields  (A Gilmore <agilmore@shaw.ca>)
List pgsql-novice
A Gilmore <agilmore@shaw.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° ;-)

pgsql-novice by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: How to get tabloid
Next
From: Terry Lee Tucker
Date:
Subject: Re: How to get tabloid