oracle 计算年龄

select floor(months_between(trunc(sysdate),date ‘1995-12-13’) / 12) age_years,
floor(mod(months_between(trunc(sysdate),date ‘1995-12-13’) , 12)) age_months,
mod(months_between(trunc(sysdate),date ‘1995-12-13’) , 1) * to_number(to_char(last_day(trunc(SYSDATE)), ‘DD’)) age_days
from dual
;

发表回复