• not a fan of all those magic numbers.... 960? 465? 450? 585?

    Also, i'm thinking the nine times "DATEADD(DD, DATEDIFF(DD, 0, @EndDate), 0)" is called, and the nine times "DATEADD(DD, DATEDIFF(DD, 0, @StartDate), 0)" is called surely takes longer than defining a variable for each and computing each once. Your mileage may vary.

    That... and it doesn't work properly. Try the following:

    select * from dbo.calcworkingHours('2014-01-01 06:00','2014-01-01 15:21');

    I'm pretty sure the answer shouldn't be negative 1.4 hours.