I currently have a column TotalHours that contain a computed column specification with the following
(isnull(datediff(minute,[RegIn],[RegOut]),(0))/(60.0))
This gives me the total hours between 2 columns regin, and regout.
Now. I am trying to subtract 30 minutes from the total hours when the computed hours is above 6.5 hours.
I tried doing it with case statement. but got lost.
Appreciate any help or pointers
Thanks.
Since you’ve got a complicated expression for the value, you’ll have to use that expression multiple times. One way to think it through is replace the complicated expression with a placeholder, like
TotalHours, then put the expression back once you figure out the logic.This says the total hours should be reduced by a value of 0.5 (30 minutes) when the total hours is larger than 6.5 hours. Writing it the way above reduces the repitions of TotalHours. Now plug the original complex expression back in: