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
|
Get Oracle SQL: the Essential Reference now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.