Divide By Zero Error

Note: This is an excerpt that is taken from a much larger query. But this is the only part that has any division. Lastly, this query is not in Epicor but it access the Sql server to run the epicor query through webpage parameters.

I keep getting a divide by zero error on this, and was wondering if anyone here could give me some idea on how to fix this.

Was thinking using NullIf, but wanted see if anyone had a better idea.

(convert(decimal, ((DATEDIFF(dd, JobHead1.StartDate,GETDATE()) + 1) - (DATEDIFF(wk, JobHead1.StartDate,GETDATE()) * 2) -(CASE WHEN DATENAME(dw, JobHead1.StartDate) = ‘Sunday’ THEN 1 ELSE 0 END) -(CASE WHEN DATENAME(dw, GETDATE()) = ‘Saturday’ THEN 1 ELSE 0 END)))/convert(decimal,((DATEDIFF(dd, JobHead1.StartDate,JobHead1.ReqDueDate) + 1) - (DATEDIFF(wk, JobHead1.StartDate,JobHead1.ReqDueDate) * 2) -(CASE WHEN DATENAME(dw, JobHead1.StartDate) = ‘Sunday’ THEN 1 ELSE 0 END) -(CASE WHEN DATENAME(dw, JobHead1.ReqDueDate) = ‘Saturday’ THEN 1 ELSE 0 END))))

NULLIF is correct way to go
see for example Calculated Field - #2 by Aaron_Moreng - ERP 10 - Epicor User Help Forum