计算SQL中的加班时间

时间:2018-01-08 04:42:50

标签: c# asp.net sql-function

我试图计算OT持续时间。但我无法找到解决方案。你能帮助我如何计算它吗? 这是我的疑问:

CASE 
    WHEN T.ScheduleId IS NULL OR T.HolidayName IS NOT NULL OR T.CheckIn IS NULL OR T.CheckOut IS NULL OR DATEDIFF(MINUTE, T.WorkingTimeTo, T.CheckOut) < CAST(@MinOTDuration AS INT) THEN 0
    WHEN DATEDIFF(MINUTE, T.WorkingTimeTo, T.CheckOut) < CAST(@MaxOTDuration AS INT) THEN DATEDIFF(MINUTE, T.WorkingTimeTo, T.CheckOut)
    ELSE
        CASE 
            WHEN DATEDIFF(MINUTE, T.WorkingTimeFrom, T.CheckIn) > CAST(@LateInGracePeriod AS INT) THEN CAST(@MaxOTDuration AS INT) 
            ELSE CAST(@EntitledOTDuration AS INT)
        END
END / 60.0 AS OTDuration

From that query, the result is 0.00

0 个答案:

没有答案