MONTHS_BETWEEN

The MONTHS_BETWEEN function returns an numeric value of the number of months between the two input dates of the function.

Format: MONTHS_BETWEEN (datetime_expression1, datetime_expression2)

Example1:

SELECT MONTHS_BETWEEN ('10-OCT-2022', '10-OCT-2018') FROM DUAL;

Result: 48 (gives that there are 48 months in between the two dates).

Example2:

SELECT MONTHS_BETWEEN ('10-OCT-2018', '10-OCT-2022') FROM DUAL;

Result: -48 (the first date is a lower (earlier) date than the second date).

Example3:

select months_between (SYSDATE+1000,SYSDATE) FROM DUAL;

Result: 32.8709677419355 (a non-integer result).