Combine Months_between, to_date, to_char together : MONTHS_BETWEEN « Date Timezone « Oracle PL / SQL






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

1.Experimenting with MONTHS_BETWEEN
2.MONTHS_BETWEEN: number of months between two dates
3.MONTHS_BETWEEN(x, y): get the number of months between x and y.
4.MONTHS_BETWEEN: Returned result is a negative number of months
5.MONTHS_BETWEEN with to_date function
6.MONTHS_BETWEEN(SYSDATE, last_stock_date)
7.ROUND(MONTHS_BETWEEN(SYSDATE, last_stock_date),0)
8.select months_between( sysdate, date'1971-05-18' )
9.select months_between( sysdate, date'2001-01-01' )
10.Count the months between now and hired date