oracle通过出生日期计算年龄

方法一:

SELECT TRUNC(months_between(sysdate, birth)/12) AS age 
from mytable

方法二:

select TRUNC((to_char(sysdate, 'yyyyMMdd') - to_char(birth, 'yyyyMMdd')) / 
             10000) as age 
from mytable



注:sysdate 为系统日期时间,birth 为表中出生日期字段



posted @ 2022-01-24 15:16  Samuel-Leung  阅读(4411)  评论(0编辑  收藏  举报