How to calculate the difference between two dates in Oracle SQL

1152125 pts.
Tags:
Oracle
Oracle SQL
I have the following table in Oracle SQL:
Filename - varchar
Creation Date - Date format dd/mm/yyyy hh24:mi:ss
Oldest cdr date - Date format dd/mm/yyyy hh24:mi:ss
So I need to calculate the difference in hours, dates and also minutes between two dates. How can I do that? Thanks.
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Arithmetic operations between dates in Oracle return their results in days, so if you want to get the difference in hours, you would multiply the results by 24. If you want it in minutes, you would multiply it by 24*60, and so on.

You could also use the TO_TIMESTAMP function to convert both dates to timestamps. That way when you substract them, you would get your results in the format: DD HH:MI:SS.MS.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • carlosdl
    Very good answer, sulica.
    85,390 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: