oracle 求时间差

create or replace function  getTime_Difference (pBeginTime in varchar2,pEndTime in varchar2)
return varchar2 is
  vTimes varchar2(100);
  vTB date := to_date(pBeginTime,'yyyy-mm-dd hh24:mi:ss');
  vTE date := to_date(pEndTime,'yyyy-mm-dd hh24:mi:ss');
begin

vTimes :=
  trunc(vTE - vTB) ||'天'||
  to_char(to_date(trunc(((vTE - vTB)-trunc(vTE - vTB))*86400),'SSSSS'),
          'fmhh24"小时"mi"分钟"'
          );
         
  return vTimes;
end  getTime_Difference ;

你可能感兴趣的:(oracle)