oracle 时间差为‘年月日’

function getTime_Difference(pBeginTime in date) return String is
    vTime varchar2(50);
  begin
    select years || '年' ||   
       months || '月' ||
       abs(    
        trunc(    
         newer_date-    
         add_months(older_date,years*12+months )    
        )    
       ) || '天' into vTime
    from (
      select trunc(months_between(newer_date, older_date )/12) YEARS,    
             mod(trunc(months_between(newer_date, older_date )),12 ) MONTHS,    
             newer_date,    
             older_date  
      from(
           select pBeginTime older_date,
                  sysdate newer_date    
           from dual
      )
    );
  return vTime;
  end;

你可能感兴趣的:(oracle)