方法一:
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 为表中出生日期字段
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/database/4096.html