SQL_MONTHS_BETWEEN1
The function "MONTHS_BETWEEN  " is unique in oracle. Similar goal can be achieved using other db like MtSQL or Postgresql, a simple way around for these data bases is shown below. 

Objectives:

  • ORACLE FUNCTIONS: MONTHS_AROUND AND SYSDATE
  • MySQL FUNCTIONS : CURENT_DATE, DATEDIFF()
  • PostGreSQL  FUNCTIONS: CURRENT_DATE,AGE

 

Oracle :

SELECT ename, sysdate "S-date",hiredate "hdate", round(months_between(sysdate,hiredate),2)"months", round(months_between(sysdate,hiredate)/12,2)"y-in-job" , round(months_between(sysdate,hiredate)* (365/12),0)"days" FROM emp where rownum < 7

POSTGRESQL:   MONTHS_BETWEEN  not supported, a way around

SELECT ename, current_date "c-date",hiredate,age(hiredate)"y-in-job" ,(current_date - hiredate) "DAYS", (current_date-hiredate)/365 "year" from emp LIMIT 6
 

MySQL : No months_between, way around

SELECT ename, hiredate, current_date "c_date", (datediff(curdate(), hiredate)/365) *12 "months",datediff(curdate(), hiredate) "days" ,datediff(curdate(), hiredate)/365 "year" from emp limit 6

 
Oracle:

 

PostgreSQL

MySQL