I have a query that calculates the hours worked from dates which includes times.
e.g 1/07/2011 7:00:00 AM - 1/07/2011 5:40:00 PM - 0.5 = 10.166666
The SQL is
SELECT entityID, StaffID, ActualDate,
DATEDIFF(minute, StartTime, EndTime) / 60.0 lunch AS HoursWorked
FROM dbo.qasiteTimesheet
StartTime
and EndTime
are both datetime
type.
Lunch
is numeric(9,1)
.
If I add whole hours e.g 6:00 AM - 5:00 PM it works fine, but add 34, 10, 2 it rounds up incorrectly.
What am I doing wrong?