Oracle MONTHS_BETWEEN Function


/ Published in: SQL
Save to your folder(s)

A few examples of the MONTHS_BETWEEN function.


Copy this code and paste it in your HTML
  1. --MONTHS_BETWEEN
  2.  
  3. SELECT MONTHS_BETWEEN(
  4. TO_DATE('01/06/2015', 'dd/mm/yyyy'),
  5. TO_DATE('07/02/2015', 'dd/mm/yyyy'))
  6. AS MB_TEST FROM dual;
  7.  
  8.  
  9. SELECT MONTHS_BETWEEN(
  10. TO_DATE('14/03/2015', 'dd/mm/yyyy'),
  11. TO_DATE('20/09/2015', 'dd/mm/yyyy'))
  12. AS MB_TEST FROM dual;
  13.  
  14. SELECT MONTHS_BETWEEN(
  15. TO_DATE('10/12/2004', 'dd/mm/yyyy'),
  16. TO_DATE('02/05/1981', 'dd/mm/yyyy'))
  17. AS MB_TEST FROM dual;
  18.  
  19.  
  20.  
  21. SELECT MONTHS_BETWEEN(
  22. TO_DATE('04/08/2015', 'dd/mm/yyyy'),
  23. TO_DATE('04/04/2015', 'dd/mm/yyyy'))
  24. AS MB_TEST FROM dual;
  25.  
  26.  
  27. SELECT MONTHS_BETWEEN(
  28. TO_DATE('11/04/2015', 'dd/mm/yyyy'),
  29. TO_DATE('11/04/2015', 'dd/mm/yyyy'))
  30. AS MB_TEST FROM dual;
  31.  
  32.  
  33. SELECT MONTHS_BETWEEN(
  34. TO_DATE('31/01/2015', 'dd/mm/yyyy'),
  35. TO_DATE('30/04/2015', 'dd/mm/yyyy'))
  36. AS MB_TEST FROM dual;

URL: http://www.databasestar.com/oracle-months_between/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.