Formula to calculate date/time difference

Job ID: 33564775

Budget: $10 – $30 USD

Hi

I am having trouble with modifying the existing formula that calculates 2 different date and time.

Basically i need to show the time difference between 2 dates and time but will only subtract the time that falls on 8PM-5AM shift. This is a timestamp tracker for work and shift is 8PM-5AM only, beyond that is no longer part of the shift.

Can someone help me solve or edit the current formula that I have for column AK and AL, it is time difference from columns X/Y (AK) and columns Z/AA (AL).

I attached the file with sample data. I would appreciate if someone can help me solve this.

I'm on a limited budget of $10 only.

Thanks in advance