Alright, so I’ve got your formulas in place. Here they are:
Let’s look at Column J first. What this function does is it first checks to see if your start time is before 6:00. If so, it subtracts your start time from 6:00 to determine how many hours were worked before 6:00. If your shift started after 6:00, a value of 0 is given. Then it checks if your shift ended after 18:00. If so, it subtracts 18:00 from your end time to determine how many hours were worked after 18:00. If it ended before 18:00, a value of 0 is given. These two values are added together. This is all enclosed in a DUR2HOURS function to give the number of hours in numerical format as you requested. Column H simply subtracts the time from column J from the length of your shift (column C) to find the time remaining, as J + H = C.
If this is not to your satisfaction, let me know and I can take another look. I notice that my column H values align with your manually calculated values, but column J does not. As the difference is not equal to D, and I have derived H from J, I’m puzzled why there would be such a discrepancy. I’m not going to say your math is wrong, but I will say I am unclear on what method you used to arrive at those figures, so I hope my formulas are acceptable.
One final note: the accuracy of these formulas is conditional upon your shifts always starting after midnight and ending before. That is to say, it assumes you are never on shift at midnight. If this is not the case, it complicates matters further. It can still be done, but an additional logic function would be needed to check for this, and adjustments made to the calculation if true. So let me know.