我需要比较2个日期,并返回2个小数位之间的天数。
例如:
比较时
SubmittedDate = 2012-02-29 07:02:55.000 FirstCall = 2012-02-29 12:12:19.000
这是5个小时的时差。所以我会退还0.2天
我试过了:
CAST(DATEDIFF(Hour, SubmittedDate, FirstCall)/30.0 AS DECIMAL(5,2)) As HoursBeforeFirstCall CAST(DATEDIFF(Day, SubmittedDate, FirstCall) AS DECIMAL(5,2)) As HoursBeforeFirstCall
似乎没有任何工作。
以DateDiff秒为单位,然后除以86400.0。小数点是必需的。
DateDiff
86400.0