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
转载于:https://www.cnblogs.com/zmztya/p/9365156.html