Avatar of anumoses
anumoses
Flag for United States of America asked on

oracle date- finding elapsed time

https://www.experts-exchange.com/questions/27540184/oracle-date-finding-elapsed-time.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.
Oracle Database

Avatar of undefined
Last Comment
anumoses

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Sean Stuber

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Sean Stuber

that will actually support up to 999 hours
anumoses

ASKER
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.
anumoses

ASKER
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,
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
anumoses

ASKER
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
anumoses

ASKER
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.
Sean Stuber

####: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
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
anumoses

ASKER
thanks