Calculate part of interval not overlapping with other interval
I am a bit stuck and was hoping one of the experts could help me.
I am busy calculating OEE and for that I need to find out which part of a batch was not overlapping with a time loss in the same shift. My mind works in pictures so maybe the following helps with the explanation:
What I essentially want is the duration green part of the batch which does not overlap with an orange time loss (or time losses) in that same shift (i.e. the amount of a batch which is blue in the picture).
1. Batches in the same shift cannot overlap.
2. Time losses in the same shift cannot overlap.
3. My example is divided into 30min blocks, but these are actually timestamps with seconds and not such fixed intervals.
The following inline tables create the Batch and TimeLoss entries in my example: