Solved

oracle date- finding elapsed time

Posted on 2012-03-19
8
411 Views
Last Modified: 2012-03-26
http://www.experts-exchange.com/Database/Oracle/Q_27540184.html

Earlier answered question.

select to_char(floor((sysdate -bleed_end_time)*24),'fm09') || ':' || to_char(round(mod((sysdate -bleed_end_time)*24,1) * 60),'fm09')
from units@qlab  
 where unit_id = 'W039712003106'

by: sdstuberPosted on 2012-01-17 at 06:28:39ID: 37447220
----------------
Now my requirement is changed. Instead of 24 hours it has to be upto 120 hours.  Need help in this. Appreciate.
0
Comment
Question by:anumoses
  • 5
  • 3
8 Comments
 
LVL 73

Accepted Solution

by:
sdstuber earned 250 total points
Comment Utility
select to_char(floor((sysdate -bleed_end_time)*24),'fm009') || ':' || to_char(round(mod((sysdate -bleed_end_time)*24,1) * 60),'fm09')
from units@qlab  
 where unit_id = 'W039712003106'
0
 
LVL 73

Expert Comment

by:sdstuber
Comment Utility
that will actually support up to 999 hours
0
 
LVL 6

Author Comment

by:anumoses
Comment Utility
TO_CHAR(FLOOR((SYSDATE-BLEED_END_TIME)*24),'FM009')||':'||TO_CHAR(ROUND(MOD((SYSDATE-BLEED_END_TIME)*24,1)*60),'FM09')

####:20

I dont think this is right.
0
 
LVL 6

Author Comment

by:anumoses
Comment Utility
select to_char(floor((sysdate -bleed_end_time)*24),'fm009') || ':'
|| to_char(round(mod((sysdate -bleed_end_time)*24,1) * 60),'fm09')
from units@qlab  
 where unit_id = 'W039712003902'

---------------
120:24

I think we are in the right direction.
Thanks,
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 6

Author Comment

by:anumoses
Comment Utility
select to_char(floor((sysdate -bleed_end_time)*24),'fm009') || ':' || to_char(round(mod((sysdate -bleed_end_time)*24,1) * 60),'fm09')
from units@qlab  
 where unit_id = 'W039712003902'

120:33
 
select (sysdate - bleed_end_time)
from units@qlab  
where unit_id = 'W039712003902'  


5.02341435185185

      select to_char(trunc(sysdate)+ 5.02341435185185,'hh24:mi')
 from dual;

00:33

Here I need to get that 120:33
0
 
LVL 6

Author Comment

by:anumoses
Comment Utility
I think I am good with the previous solution. Instead of converting further, I am diplaying the first value of 120:33 . Will make further tests and let you know. Thanks.
0
 
LVL 73

Expert Comment

by:sdstuber
Comment Utility
####:20  --- this means the result was 4 digits, i.e.  > 999 hours

if you need to display a results that large
change

this:   to_char(floor((sysdate -bleed_end_time)*24),'fm009')


to:   to_char(floor((sysdate -bleed_end_time)*24),'fm0009')

you can keep adding 0s to the format to expand as needed.



I'm not sure what you were trying to say in http:#a37739663
0
 
LVL 6

Author Closing Comment

by:anumoses
Comment Utility
thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now