我试图计算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