s.LastName + ',' + s.FirstName as formattedName
,t.Date
,RIGHT (t.In1, 7) AS TineIn1
,RIGHT (t.Out1, 7) AS TimeOut1
,RIGHT (t.In2, 7) AS TimeIn2
,RIGHT (t.Out2, 7) AS TimeOut1
,RIGHT (t.In3, 7) AS TimeIn3
,RIGHT (t.Out3, 7) AS TimeOut3
, (ISNULL(DATEDIFF(second,t.IN1,t.Out1),0)
+ISNULL(DATEDIFF(second,t.IN2,t.Out2),0)
+ISNULL(DATEDIFF(second,t.IN3,t.Out3),0))/3600.0 AS WorkedHours
我可以获得一天的总时数,但是我如何才能获得一周的总工作时间以及一个月的工作时间。
答案 0 :(得分:0)
select employee_fullname,
(select (ISNULL(DATEDIFF(second,t.IN1,t.Out1),0)
+ISNULL(DATEDIFF(second,t.IN2,t.Out2),0)
+ISNULL(DATEDIFF(second,t.IN3,t.Out3),0))/3600.0 AS WorkedHours
from timesheet
where t.in1 between 'cut-off-start' and 'cut-off-end' ) totalHoursWorked
from employeemaster
如果t.in1表示当天的第一次。
截止开始/截止结束(日期范围,无论是周还是月)