Incorrect Syntax


(William) #1

Keep getting an syntax error. I’ve been working on this all day and I can’t find it for the life of me. This is going into a BAQ Calc field.

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


(William) #2

Found it. Needed an extra parenthesis at the end of the first part before the division. Crazy! One things took me several hours. Gotta love it.