Question : Date Calculation

Hi Experts,

If I had to dates which are date fieds in a oracle database and i want to find out the duration of time.  START_DATE  and COMPLETED_DATE.  I want to see it in days and hours and min I would I write the select statement.

Thanks

Answer : Date Calculation

select (COMPLETED_DATE - START_DATE) as diff_days

it will be a real number like 1.23423 meaning 1 day and 0.23423 x 24 = 5.62152 hours
maning 5 hours + 0.62152 * 60 = 37.2912 minutes
meaning 37 minutes and 0.2912 * 60 = 17.472 seconds ;)

if you multiply the difference with 24*60*60, you will end up seconds

select (COMPLETED_DATE - START_DATE)* (24*60*60) as diff_seconds
Random Solutions  
 
programming4us programming4us