| MONTHS_BETWEEN |
MONTHS_BETWEEN(d1,d2) |
Returns the number of months between the two dates d1 and d2.
If both dates represent the same day of the month or represent the last day of their respective months, an integer value will be returned. Otherwise, MONTHS_BETWEEN will return a fractional value.
Examples
SQL> SELECT MONTHS_BETWEEN(TO_DATE('29-Dec-1999'), TO_DATE('29-Dec-1988'))
2 FROM dual;
MONTHS_BETWEEN(TO_DATE('29-DEC-1999'),TO_DATE('29-DEC-1988'))
-------------------------------------------------------------
132
SQL> SELECT MONTHS_BETWEEN(TO_DATE('12-May-2000'), TO_DATE('29-Dec-1988'))
2 FROM dual;
MONTHS_BETWEEN(TO_DATE('12-MAY-2000'),TO_DATE('29-DEC-1988'))
-------------------------------------------------------------
136.451613
|
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
