Interval fields
Interval fields
От:
A Gilmore <agilmore@shaw.ca>
Дата:
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? Thank you, - A Gilmore
Re: Interval fields
От:
Kretschmer Andreas <andreas_kretschmer@despammed.com>
Дата:
A Gilmore 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° ;-)