Thursday, August 24, 2017

year month days

select join_dt, sysdate         ,trunc(months_between(sysdate, join_dt) / 12) as yrs
         ,trunc(mod(months_between(sysdate, join_dt), 12)) as mnths
        ,trunc(sysdate - add_months(join_dt, trunc(months_between(sysdate, join_dt)))) as dys from emp_mast where emp_id='010001'

 JOIN_DT   SYSDATE          YRS      MNTHS        DYS
--------- --------- ---------- ---------- ----------
01-NOV-10 24-AUG-17          6          9         23

No comments:

Post a Comment

 https://www.linkedin.com/pulse/building-real-time-database-monitoring-dashboard-oracle-khaleeq-tpwxf/