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

posted @ 2018-07-25 11:51  zmztyas  阅读(3679)  评论(0编辑  收藏  举报