=IF(C6>TIME(22;0*E6>TIME(5;0;SUM(E6-C6)+(C6>E6)*1)

What I have done by far, resulted with this formula in column H.
But, if the time in column C and column E is not between 22:00 and 05:00 I'm getting the same result like in column F, which is not correct.

Any help is very worm welcome.