0
Thanks

A few words of thanks would be greatly appreciated.

Equivalent of DATEDIFF function of the SQL Server under Oracle.

DATEDIFF is a common function in the SQL Server to find the number of days between two dates. Oracle offers its own solution, although does not have the DATEDIFF function.




Issue

So, what's the function in Oracle that would be the equivalent to DATEDIFF in the SQL Server?

Solution

On Oracle, it is an arithmetic issue:
select DATE1-DATE2 from dual 


Use trunc() for the number of days.

Otherwise, multiply the value:
  • by 24 for hours
  • by 1440 for minutes
  • by 86400 for seconds


Image: © Unsplash
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
Related
This document, titled « Equivalent of DATEDIFF function of the SQL Server under Oracle. », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!