数据库
首页 > 数据库> > oracle 周岁年龄计算

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

  

标签:sysdate,csrq,yyyy,char,算法,oracle,年龄,周岁,SELECT
来源: https://www.cnblogs.com/iupoint/p/11103168.html