sql 两时间做差取出来天时分秒

  right('00'+ cast(cast(datediff(ss ,DT1,DT2) / 86400 as int) as varchar),2) + '天' + 

  right('00'+ cast(cast(datediff(ss ,DT1,DT2) % 86400 / 3600 as int) as varchar),2) + '时' + 

  right('00'+ cast(cast(datediff(ss ,DT1,DT2) % 86400 % 3600 / 60 as int) as varchar),2) + '分' + 

  right('00'+ cast(cast(datediff(ss ,DT1,DT2) % 86400 % 3600 % 60 as int) as varchar),2)+'秒' AS 时间差,

你可能感兴趣的:(sql 两时间做差取出来天时分秒)