SQLTeam.com | Weblogs | Forums

Calculate Hours Worked


#1

Hi,

I have two columns, Start_Shift and End_Shift. How do I calculate the hours worked?

thanks


#2

You did not say what datatype Start_Shift and End_Shift are. If they are DATETIME you could use DATEDIFF


#3
SELECT DATEDIFF(HOUR, Start_Shift, End_Shift) HoursCalc

#4

thank you for your help that has worked perfectly.

thanks again


#5

Because of the way DATEDIFF works, it's much safer to use MINUTE rather than HOUR:

SELECT CAST(DATEDIFF(MINUTE, Start_Shift, End_Shift) / 60.0 AS decimal(6, 2)) AS HoursCalc


#6

Thank you for your help :blush: