DEV Community

AntDB
AntDB

Posted on

AntDB-Oracle Compatibility Developer’s Manual P3–41

MONTHS_BETWEEN

The MONTHS_BETWEEN function returns the number of months between 2 dates. If the first date is greater than the second date, then the return result is a positive value, otherwise the return result is a negative number.

If all date arguments have the same date in the month, or if all date arguments are the last day of the month respectively, then the result is the whole number of months.

Example:

SELECT MONTHS_BETWEEN('15-DEC-06','15-OCT-06') FROM DUAL;

MONTHS_BETWEEN('15-DEC-06','15-OCT-06')  
------------------------------------------
                                        2
(1 row)


SELECT MONTHS_BETWEEN('15-OCT-06','15-DEC-06') FROM DUAL;

MONTHS_BETWEEN('15-OCT-06','15-DEC-06')  
------------------------------------------
                                       -2
(1 row)


SELECT MONTHS_BETWEEN('31-JUL-00','01-JUL-00') FROM DUAL;

MONTHS_BETWEEN('31-JUL-00','01-JUL-00')  
------------------------------------------
                        0.967741935483871
(1 row)


SELECT MONTHS_BETWEEN('01-JAN-07','01-JAN-06') FROM DUAL;

MONTHS_BETWEEN('01-JAN-07','01-JAN-06')  
------------------------------------------
                                       12
(1 row)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)