Oracle ADD_MONTHS Function


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

A few examples of the ADD_MONTHS function


Copy this code and paste it in your HTML
  1. SELECT SYSDATE,
  2. ADD_MONTHS(SYSDATE, 1) AS ADD_MONTH_RESULT
  3. FROM dual;
  4.  
  5. SELECT SYSDATE,
  6. ADD_MONTHS(SYSDATE, 6) AS ADD_MONTH_RESULT
  7. FROM dual;
  8.  
  9.  
  10. SELECT SYSDATE,
  11. ADD_MONTHS(SYSDATE, 41) AS ADD_MONTH_RESULT
  12. FROM dual;
  13.  
  14.  
  15. SELECT SYSDATE, ADD_MONTHS(SYSDATE, -6) AS ADD_MONTH_RESULT
  16. FROM dual;
  17.  
  18.  
  19. SELECT SYSDATE, ADD_MONTHS(SYSDATE, '5') AS ADD_MONTH_RESULT
  20. FROM dual;
  21.  
  22.  
  23. SELECT SYSDATE, ADD_MONTHS(SYSDATE, 'Six') AS ADD_MONTH_RESULT
  24. FROM dual;
  25.  
  26. SELECT TO_DATE('08-JUL-2015') AS INPUT_DATE,
  27. ADD_MONTHS(TO_DATE('08-JUL-2015'), 1) AS ADD_MONTH_RESULT
  28. FROM dual;
  29.  
  30.  
  31. SELECT SYSDATE,
  32. ADD_MONTHS(SYSDATE, 2.3) AS ADD_MONTH_RESULT_LOW,
  33. ADD_MONTHS(SYSDATE, 2.9) AS ADD_MONTH_RESULT_HIGH
  34. FROM dual;
  35.  
  36.  
  37. SELECT SYSDATE, ADD_MONTHS(SYSDATE, 12) AS ADD_MONTH_RESULT
  38. FROM dual;
  39.  
  40.  
  41. SELECT SYSDATE,
  42. TRUNC(ADD_MONTHS(LAST_DAY(SYSDATE)+1,-1)) AS FIRST_DAY
  43. FROM dual;

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.