Get the number of days between two dates in Oracle, inclusive of the dates
Solution 1:
In Oracle substracting two dates returns the number of days between two dates.
A minus
operator works in the same way as for numbers:
20 - 20 = 0 ===> 2013-05-20 - 2013-05-20 = 0
25 - 20 = 5 ===> 2013-05-25 - 2013-05-20 = 5
If you want to include last number
or last date
, you need to add 1:
20 - 20 + 1 = 1 ===> 2013-05-20 - 2013-05-20 + 1 = 1
25 - 20 + 1 = 6 ===> 2013-05-25 - 2013-05-20 + 1 = 6