Home » RDBMS Server » Server Administration » Sum a volume in seconds, transform it to HH:MI.SS...
Sum a volume in seconds, transform it to HH:MI.SS... [message #373432] Tue, 17 April 2001 03:33 Go to next message
TiĀ“ger
Messages: 1
Registered: April 2001
Junior Member
Hi!
I have been struggling with a way to format output from a query. The query returns the sum in seconds for mobile traffic. I want this sum (if possible) to be presented like 22:34:54 (hours:minutes:seconds). Anyone out there that can help me?

/Tiger
Re: Sum a volume in seconds, transform it to HH:MI.SS... [message #373443 is a reply to message #373432] Tue, 17 April 2001 12:48 Go to previous message
Bala
Messages: 205
Registered: November 1999
Senior Member
Hi,

have a function
-----------------

create or replace function timefunc(psum number) return
varchar2 as

hh number;
mi number;
ss number;
newtime varchar2(15);

begin
hh := floor(psum/3600);

mi := floor(mod(psum, 3600) / 60);

ss := psum - ((hh * 3600) + (mi * 60));

newtime := hh || ':' || mi || ':' || ss;

return newtime;

end;

/
---------------------------------------
this function will accept your sum in numeric format and will return time in varchar format.
and you can use this function to convert your sum in seconds into HH:MI:SS

like

SQL> select timefunc(5634) from dual;

TIMEFUNC(5634)
---------------------------------------------
1:33:54

Bala.
Previous Topic: Re: How can i copy tables !!!
Next Topic: Format of Export & Import Commands
Goto Forum:
  


Current Time: Tue Jul 02 18:11:30 CDT 2024