/ Published in: SQL
A few examples of the MONTHS_BETWEEN function.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
--MONTHS_BETWEEN SELECT MONTHS_BETWEEN( TO_DATE('01/06/2015', 'dd/mm/yyyy'), TO_DATE('07/02/2015', 'dd/mm/yyyy')) AS MB_TEST FROM dual; SELECT MONTHS_BETWEEN( TO_DATE('14/03/2015', 'dd/mm/yyyy'), TO_DATE('20/09/2015', 'dd/mm/yyyy')) AS MB_TEST FROM dual; SELECT MONTHS_BETWEEN( TO_DATE('10/12/2004', 'dd/mm/yyyy'), TO_DATE('02/05/1981', 'dd/mm/yyyy')) AS MB_TEST FROM dual; SELECT MONTHS_BETWEEN( TO_DATE('04/08/2015', 'dd/mm/yyyy'), TO_DATE('04/04/2015', 'dd/mm/yyyy')) AS MB_TEST FROM dual; SELECT MONTHS_BETWEEN( TO_DATE('11/04/2015', 'dd/mm/yyyy'), TO_DATE('11/04/2015', 'dd/mm/yyyy')) AS MB_TEST FROM dual; SELECT MONTHS_BETWEEN( TO_DATE('31/01/2015', 'dd/mm/yyyy'), TO_DATE('30/04/2015', 'dd/mm/yyyy')) AS MB_TEST FROM dual;
URL: http://www.databasestar.com/oracle-months_between/