From the course: Oracle Database 12c: Basic SQL

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Using MONTHS_BETWEEN

Using MONTHS_BETWEEN

- [Instructor] The Oracle months_between function allows us to calculate how may months have passed between two distinct dates. Let's see it in action. We'll start by selecting the current sysdate and the hire_date column from the employees table. Note that since sysdate is a pseudocolumn, that is, it is calculated on the fly, and returns the current date and time, of the Oracle database server, while hire_date is an actual column of the employees table, the output will show us a repeating sysdate value for each row returned, while the hire_date column will actually show us the date when the employee was hired. That's because, again, sysdate is calculated on the fly. It's a pseudocolumn, not part of the table, while hire_date is indeed retrieved from the employees table. Okay, so back to business. So let's say we were calculate how many months have passed between the current date, sysdate, and the hire date of the…

Contents