Combine Months_between, to_date, to_char together
SQL>
SQL> SELECT MONTHS_BETWEEN(TO_DATE(TO_CHAR(TO_DATE('&date1'),
2 'mmyyyy'), 'mmyyyy'),
3 TO_DATE(TO_CHAR(TO_DATE('&date2'), 'mmyyyy'),
4 'mmyyyy')) Diff_Date
5 FROM DUAL;
Enter value for date1:
old 1: SELECT MONTHS_BETWEEN(TO_DATE(TO_CHAR(TO_DATE('&date1'),
new 1: SELECT MONTHS_BETWEEN(TO_DATE(TO_CHAR(TO_DATE(''),
Enter value for date2:
old 3: TO_DATE(TO_CHAR(TO_DATE('&date2'), 'mmyyyy'),
new 3: TO_DATE(TO_CHAR(TO_DATE(''), 'mmyyyy'),
DIFF_DATE
----------
Page 1
SQL>
Related examples in the same category