Обсуждение: interval

Поиск
Список
Период
Сортировка

interval

От
"Yuri A. Kabaenkov"
Дата:
Hello,

      How can i get time interval only in minutes or in seconds ?

      For example i have '1 month 15 days' and i need these time in
      minutes.





------------
With respect,
Yuri A. Kabaenkov
hellman@artofit.com


Re: interval

От
Thomas Lockhart
Дата:
>       How can i get time interval only in minutes or in seconds ?
>       For example i have '1 month 15 days' and i need these time in
>       minutes.

lockhart=# select extract(epoch from interval '1 month 15 days') / 60;
 ?column?
----------
    64800
(1 row)

                      - Thomas

Re: interval

От
"Yuri A. Kabaenkov"
Дата:
Hello Thomas,

Monday, December 03, 2001, 8:01:45 PM, you wrote:

>>       How can i get time interval only in minutes or in seconds ?
>>       For example i have '1 month 15 days' and i need these time in
>>       minutes.

TL> lockhart=# select extract(epoch from interval '1 month 15 days') / 60;
TL>  ?column?
TL> ----------
TL>     64800
TL> (1 row)

Oh...thanks one more question.

I create these function:

CREATE FUNCTION sum_revenue() RETURNS real AS '

DECLARE
call RECORD;


BEGIN
        tmpsum := 0;
                FOR call IN SELECT
                country,(date_part('epoch), starttime - endtime)::float AS seconds ,type from calls where sub_acc = 4
LOOP
                        RETURN call.minutes;
                END LOOP;
 end;
' LANGUAGE 'plpgsql';

And in call.minutes i've got '0';

Why ? How can i retrive call.minutes ?

these RETURN only for debug.



TL>                       - Thomas



------------
With respect,
Yuri A. Kabaenkov
hellman@artofit.com