Oracle计算年龄

--算法一:
SELECT TRUNC(months_between(sysdate, csrq)/12) AS "Age" FROM wrxxb;

--算法二:
SELECT trunc(to_number(to_char(sysdate,'yyyymmdd'))/10000 - to_number(to_char(to_date('1982-8-28','yyyy-mm-dd'),'yyyymmdd'))/10000) FROM dual;

--算法三:

SELECT to_char(sysdate,'yyyy')-to_char(csrq,'yyyy')+ decode(sign(to_char(sysdate,'mmdd')-to_char(csrq,'mmdd')),-1,-1,0,0,1,0) FROM wrxxb

 

posted @ 2015-10-10 10:10  韩梦芫  阅读(3466)  评论(0编辑  收藏  举报