Calculating Hours Worked From Schedule
Posted: Tue Jan 28, 2014 9:39 am
I'm having an issue trying to calculate the number of hours worked for our providers. We don't use the timecard (our providers are paid salary), but I do have the schedule setup with individual providers' schedules. We stagger our lunches, so one provider may have a lunch break starting at say 12:20 while another one has it at 1:00. When I try to summarize the hours worked I'm not coming up with an accurate result.
Here's our schedule that I'm working with:

Here's the code I'm using:
And here's the result:

Any ideas???
Here's our schedule that I'm working with:

Here's the code I'm using:
Code: Select all
SET @FromDate = '2014-01-27', @ToDate = '2014-01-27';
SELECT ProvNum, SUM(HOUR(TIMEDIFF(StopTime, StartTime))) AS 'Hours'
FROM schedule
WHERE SchedDate BETWEEN @FromDate AND @ToDate
AND SchedType = 1 /* Provider */
GROUP BY ProvNum
Any ideas???