I've looked around and have tried other solutions I've seen posted for similar questions but none have worked completely.
This is a sample of the data.
Formula for day hours currently is:
=MAX(,MIN(D2,IF(B2<A2,1,)+B2)-MAX(A2,C2))
Night hours:
=E2-F2
It appears to work in all day shift start...