w3resource

Oracle: Number of days between two given dates

Oracle Datetime: Exercise-7 with Solution

Write a Oracle SQL statement to get number of days between two given dates.

Sample Solution:

Oracle Code:

SELECT ROUND ((MONTHS_BETWEEN ('01-May-2024', '01-Dec-2023') * 30), 0) num_of_days FROM DUAL;  

Output:

  	NUM_OF_DAYS
1	150

Improve this sample solution and post your code through Disqus.

Previous: Write a Oracle SQL statement to get the number of days in current month.
Next: Write a Oracle SQL statement to get the start date and end date of each month in current year from current month.

What is the difficulty level of this exercise?



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/oracle-exercises/datetime/oracle-datetime-exercise-7.php