oracle 根据出生日期计算年龄的年月日

select years,months,abs(
trunc(
newer_date-
add_months( older_date,years*12+months )
)
) days from (select
trunc(months_between( to_date('20180625', 'yyyymmdd'), to_date('19960626', 'yyyymmdd') )/12) YEARS,
mod(trunc(months_between(to_date('20180625', 'yyyymmdd'), to_date('19960626', 'yyyymmdd') )),12 ) MONTHS,
to_date('20180625', 'yyyymmdd') newer_date,
to_date('19960626', 'yyyymmdd') older_date
from dual) shisui

猜你喜欢

转载自www.cnblogs.com/zmztya/p/9365156.html