SQL两次之间的差异,以秒为单位

时间:2016-06-29 23:12:52

标签: time sql-server-2012 seconds

SELECT   Warehouses.Name,
         RIGHT(CONVERT(VARCHAR,AirwayBillTrucks.CheckOutTime,100),7) AS CheckOutTime,
         RIGHT(CONVERT(VARCHAR,AirwayBillTrucks.ReturnTime,100),7) AS ReturnTime

这是我的一段代码,CHECKOUTTIME和RETURNTIME曾经是DATETIME DD-DD-YYYY HH-MM-SS,但我将它们转换成TIME HH-MM-SS tt,这对我来说很好。现在我需要在几秒钟内完成这两列之间的差异,

1 个答案:

答案 0 :(得分:0)

SELECT DATEDIFF(ss,CheckOutTime,CheckInTime)