Re: Interval fields

Поиск
Список
Период
Сортировка
От Kretschmer Andreas
Тема Re: Interval fields
Дата
Msg-id 20050930173802.GA2307@kaufbach.delug.de
обсуждение исходный текст
Ответ на Interval fields  (A Gilmore <agilmore@shaw.ca>)
Список 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 по дате отправления:

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: How to get tabloid
Следующее
От: Terry Lee Tucker
Дата:
Сообщение: Re: How to get tabloid