interval

Started by Yuri A. Kabaenkovover 24 years ago3 messagesgeneral
Jump to latest
#1Yuri A. Kabaenkov
sec@artofit.com

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

#2Thomas Lockhart
lockhart@fourpalms.org
In reply to: Yuri A. Kabaenkov (#1)
Re: interval

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

#3Yuri A. Kabaenkov
sec@artofit.com
In reply to: Thomas Lockhart (#2)
Re: interval

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