RE: Elapsed Time

  • From: "Bobak, Mark" <Mark.Bobak@xxxxxxxxxxxxxxx>
  • To: <DGoulet@xxxxxxxx>, "_oracle_L_list" <oracle-l@xxxxxxxxxxxxx>
  • Date: Fri, 19 May 2006 13:39:04 -0400

It's just some pretty simple and straightforward math.  Try something
like this:

SQL> variable seconds_elapsed number
SQL> exec :seconds_elapsed := 20000;

PL/SQL procedure successfully completed.

SQL> select trunc(:seconds_elapsed/3600) hours, trunc((:seconds_elapsed
- trunc(:seconds_elapsed/3600)*3600)/60) minutes, :seconds_elapsed -
(trunc(:seconds_elapsed/60)*60) seconds from dual

     HOURS    MINUTES    SECONDS
---------- ---------- ----------
         5         33         20

SQL> exec :seconds_elapsed := 178

PL/SQL procedure successfully completed.

SQL> /

     HOURS    MINUTES    SECONDS
---------- ---------- ----------
         0          2         58

SQL> exec :seconds_elapsed := 0

PL/SQL procedure successfully completed.

SQL> /

     HOURS    MINUTES    SECONDS
---------- ---------- ----------
         0          0          0

SQL> exec :seconds_elapsed := 100000

PL/SQL procedure successfully completed.

SQL> /

     HOURS    MINUTES    SECONDS
---------- ---------- ----------
        27         46         40 


Hope that helps,

-Mark

--
Mark J. Bobak
Senior Oracle Architect
ProQuest Information & Learning

For a successful technology, reality must take precedence over public
relations, for Nature cannot be fooled.  --Richard P. Feynman, 1918-1988


-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx
[mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Goulet, Dick
Sent: Friday, May 19, 2006 1:12 PM
To: _oracle_L_list
Subject: Elapsed Time

Folks,

        Before I go off re-inventing the wheel, and yes I still have to
scan AskTom, but here's by "problem".

        I've a developer who has calculated the elapsed time of some
database action, whatever it is, and he wants to display the result to
the user, but not as a pile of seconds.  He wants to convert it into
hours, minutes, and seconds so that the display comes out as a character
string looking like "x hours y minutes z seconds".  Anyone done that
before.

Dick Goulet
Senior Oracle DBA
Oracle Certified DBA
--
//www.freelists.org/webpage/oracle-l


--
//www.freelists.org/webpage/oracle-l


Other related posts: