sql 以年月日的方式显示所有员工的服务年限

SELECT ename, hiredate, 
trunc(MONTHS_BETWEEN(SYSDATE,hiredate) /12)  year  ,
trunc(MOD(MONTHS_BETWEEN(SYSDATE,hiredate) ,  12 ) ) months  , 
trunc(SYSDATE - ADD_MONTHS(hiredate,months_between(sysdate,hiredate))) day
FROM emp ;
posted @ 2012-10-23 00:53  一布  阅读(3089)  评论(0编辑  收藏  举报