Calculate Hours Worked

Hi,

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

thanks

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

1 Like
SELECT DATEDIFF(HOUR, Start_Shift, End_Shift) HoursCalc
1 Like

thank you for your help that has worked perfectly.

thanks again

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

1 Like

Thank you for your help :blush: