GeekInterview.com
Series: Subject: Topic:
Question: 5 of 33

how to subtract 2 dates in oracle to get in hour and minute

I want to subtract 2 dates and represent the result in hour and minute in one decimal figure. I have the following table and i am doing it in this way but the result is not as desired. There is some slight variation, im sure this is simple arithmetic but im not getting it right. select start_time, end_time, (end_time-start_time)*24 from come_leav; START_TIME END_TIME (END_TIME-START_TIME)*24 ------------------- ------------------- ------------------------ 21-06-2011 14:00:00 21-06-2011 16:55:00 2.9166667 21-06-2011 07:00:00 21-06-2011 16:50:00 9.8333333 21-06-2011 07:20:00 21-06-2011 16:30:00 9.1666667 I want the result (end_time-start_time) as below. 16:55- 14:00 = 2.55 16:50-07:00 = 9.5 16:30-7:20 = 9.1 and so on. Please help. Any help will be much appreciated x 1000 times. Regards, Mack
Asked by: K Mack Ahmed | Member Since Sep-2011 | Asked on: Sep 18th, 2011

View all questions by K Mack Ahmed

Showing Answers 1 - 1 of 1 Answers
Shalini

Answered On : Jul 12th, 2012

You can try like below.

select to_number(16.55,99.99)-to_number(14.00,99.99)
from dual;

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.