PL/SQL Months_Between

Oracle PL/SQL Months_Between Function

The Months_Between is used to show the number of months between two dates.

The Months_Between Function syntax:

months_between( date1, date2 )

Example:

Select months_between(to_date('2010/06/06','yyyy/mm/dd'),to_date('2010/09/06','yyyy/mm/dd')) From dual;
-3

Select months_between(to_date('2010/09/20','yyyy/mm/dd'),to_date('2010/05/26','yyyy/mm/dd')) From dual;
3.80645161290323

Select months_between (to_date('2010/09/20','yyyy/mm/dd'),to_date('2010/09/20','yyyy/mm/dd')) From dual;
0

Select months_between (to_date('2010/09/25','yyyy/mm/dd'),to_date('2010/05/25','yyyy/mm/dd')) From dual;
4