My apologies, but it turns out I need further assistance - I thought the examples I gave would suffice for all my various cases, but it appears not, as I believe I have more issues remaining.
The 1st issue...
Premium hours ranges don't always cross over midnight - they could occur between any time range, on any given day, and may involve only one day, or two. Let's use the following revised example:
Example 4
Cell A1 = 08:00
Cell B1 = 20:00
Cell C1 = 06:00 (same as the original example above)
Cell D1 = 16:00 (same as the original example above)
Excel formula should return a value of 10.00, but in using Vijay's formula I get a value of 4.00
The 2nd issue...
'Weekends' involve special premium ranges, which can run from some time on Friday evening, and last until sometime Monday morning. As such, I now need to be able to establish a separate set of premium hour ranges to individually define the ranges that apply
to the Friday evening portion, all day Saturday, all day Sunday, and some portion of Monday.
The following to clarify:
Let's set Cell E1 at 20:00 to represent the start of the Friday weekend premium range.
Let's set Cell F1 at 24:00 to represent the end of the Friday weekend premium range.
Let's set Cell G1 at 00:00 to represent the start of the Saturday weekend premium range.
Let's set Cell H1 at 24:00 to represent the end of the Saturday weekend premium range.
Let's set Cell I1 at 00:00 to represent the start of the Sunday weekend premium range.
Let's set Cell J1 at 24:00 to represent the end of the Sunday weekend premium range.
Let's set Cell K1 at 00:00 to represent the start of the Monday weekend premium range.
Let's set Cell L1 at 06:00 to represent the end of the Monday weekend premium range.
The problem I'm having here is that when I try to set the value of Cell F1, H1 or J1 at midnight (i.e. 2400), excel automatically changes the value in cell to '00:00'. How should I deal with this in a manner that will still allow your solution formula
to work?
If we can solve the two issues above, I believe I can deal with determining which hours fall into which weekend period, and properly calculate the premium hours.
Thanks once again for your time and effort.