Job Times BAQ

I’m trying to create a BAQ that will calculate the times between operations of a job. This would include the planned times and the actual times. We’re trying to find bottlenecks.
I can get the times OK, it’s just the math, trying to calculate ‘Start to End’ for each op and ‘Start to Start’ for each op, along with the planned ‘Start to End’ and the actual ‘Start to End’ for the entire job. (along with the added fun of taking weekends and holidays out of the picture)

This is what I use to remove weekends.
((datediff(d, (dateadd(d,8 - datepart(dw,JobHead.ReadyForMOMDate_c),JobHead.ReadyForMOMDate_c)),(dateadd(d, 1 - datepart(dw, DateEng), DateEng))) * 5 /7) + (datediff(d, JobHead.ReadyForMOMDate_c, (dateadd(d,8 - datepart(dw,JobHead.ReadyForMOMDate_c),JobHead.ReadyForMOMDate_c))) - 1) + (datediff(d, (dateadd(d, 1 - datepart(dw, DateEng), DateEng)), DateEng)) - (case when datepart(dw,JobHead.ReadyForMOMDate_c) = 1 then 1 else 0 end) - (case when datepart(dw, DateEng) = 7 then 1 else 0 end)) + -1

Thanks, I’ll give that a try.

Have you considered using MRP to do this work for you (the whole “finding bottlenecks” thing)?

Maybe bottleneck isn’t the right term.
We’re going back in time a bit. Trying to compare each time we run a job.
We’ve noticed one part in particular that runs pretty close to estimate half the time, and about 1.5 times estimate the other times. After talking to some of the guys in the shop, we found the cause and we’re working on fixing it.
We have other jobs that run in an acceptable amount of time, but there is a lot of start and stop, which shows up as a total elapsed time of say, 20 days, but we only worked on it for maybe 16 actual hours.
We’re basically trying to find these situations and identify causes.