Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Time arithmetic in Oracle & WebDB
Folks
I've been scratching my head over something that I'm certain has been solved several times before. I have a table that has a column of "times", that is, the real number of minutes that something happened per day. For example, if I was a runner and tracking the number of minutes I ran in a month, this table would look like:
Day Minutes ran
---- -----------
1 45
2 98
3 37
4 102
and so on. Now, I need to generate a report which displays the time in HH24:MI format. I thought, no problem, in the SQL statement for the WEBDB report just use this:
select STATDATE "Day", TO_CHAR(TRUNC(RUNTIME/60),'09')||':'||TO_CHAR(MOD
(RUNTIME,60),'09') "Minutes ran"
which does work. However, I also need to generate column totals. I have quite a few columns of this sort of info.
So, my questions are:
a) should I try to convert time? That is, I have successfully tried:
to_char(to_date('01-JAN-1970','DD-MON-YYYY')+(RUNTIME/
(60*24) ),'HH24:MI') "Minutes ran"
But WebDB's total result for this column is 0. I *really* need accurate times in the totals. Do I need to 'Add advanced PL/SQL code'? What I'd really like to show is a total format that's a number of hours that can be larger than 24 ":" MM. For example, someone might run 122:14 hours in a month.
b) should I abandon the convert to time approach and go back to straight math, then write some crazy stored procedure to convert everything back?
c) am I nutz for attempting such a thing in WebDB?
Many thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Fri Jun 09 2000 - 00:00:00 CDT