subtract date in SQL

my table structure is like this

Table Name : Receive
Field Name         Field Type
 FileName          Varchar2(50)    
 StartDateTime     Date
 EndDateTime       Date
 TotalRecord       Number

i want to know Total time process in hour:minute:second

the output is more like this:
FileName     : A.GFD
StartDateTime: 20-Nov-1999 10:00:00
EndDateTime  : 20-Nov-1999 15:23:33
Process Time : 03:23:33   <-- i want the process time in this format(hh:mi:ss)

how to do it ?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


SELECT floor((enddatetime-startdatetime)*24)
"Diff time in HH24:MI:SS" FROMreceive;

Hope this helps you!

SELECT floor((enddatetime-startdatetime)*24)                            ||':'||MOD((enddatetime-startdatetime)*1440,60)||':'||
                      "Diff time in HH24:MI:SS" FROM receive;
Mark GeerlingsDatabase AdministratorCommented:
Sganta's proposed solution looks good as long as the start time and end times are in the same day.  I've developed a PL\SQL function to handle a situation similar to yours where sometimes the start and end times are near midnight, but in different days.

Leave a comment here if the proposed solution does not give you what you wanted.
hdrikAuthor Commented:
  i agree with markgeer, your proposed answer only work at the same day

  can you help me ?
The following will give you the hours minutes and seconds  correctly even is the days are different  in the two dates

SELECT  floor((enddatetime-startdatetime)*24)||':'|| to_char(mod(floor((enddatetime-startdatetime)*1440),60),'09')||':'||to_char(mod((enddatetime-startdatetime)*86400,60),'09')
FROM Receive;


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.