Re: Interval to number

Поиск
Список
Период
Сортировка
От Brian McCane
Тема Re: Interval to number
Дата
Msg-id 20020520113223.I80087-100000@fw.mccons.net
обсуждение исходный текст
Ответ на Interval to number  ("Gareth Kirwan" <gbjk@thermeoneurope.com>)
Ответы Re: Interval to number  ("Gareth Kirwan" <gbjk@thermeoneurope.com>)
Список pgsql-admin
EXTRACT is your friend :)

SELECT EXTRACT(EPOCH FROM max(occurrance) - min(occurrance))::integer ;

- brian

k=# SELECT EXTRACT(EPOCH FROM now() - '2001-01-01') ;
   date_part
----------------
 43583467.94995
(1 row)


On Mon, 20 May 2002, Gareth Kirwan wrote:

>
> Postgres 7.2
> I have an interval selected from a max(occurance) - min(occurance) where
> bla.
> I now want to multiply this by a rate - to create a charge...
>
> If I use to_char( interval, 'SSSS');
> I will get a seconds conversion - but that works on seconds since midnight -
> hence
> with a one day period.
>
> Are there any better ways of converting a timestamp to an integer?
>
>
> Thanks
>
> Gareth
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

Wm. Brian McCane                    | Life is full of doors that won't open
Search http://recall.maxbaud.net/   | when you knock, equally spaced amid those
Usenet http://freenews.maxbaud.net/ | that open when you don't want them to.
Auction http://www.sellit-here.com/ | - Roger Zelazny "Blood of Amber"


В списке pgsql-admin по дате отправления:

Предыдущее
От: "Luis Andaluz P,"
Дата:
Сообщение: Informacion
Следующее
От: "Gareth Kirwan"
Дата:
Сообщение: Re: Interval to number