This isn't fully tested nor complete because I don't really understand what you're asking when you say there are 2 hours between 1:00:00 AM and 1:59:59 AM - seems to me that would be 1 hour.
But maybe you can use this. I'm assuming you want something in the cells below the hour headings I10:AG10 to indicate ON times broken down for each hour.
With that in mind place this formula in J12 and drag over to AF12 and down
=IF(AND($E12=1,HOUR($B12)=COLUMNS($I12:I12)),1/24*COLUMNS($I12:J12)-$B12,IF(AND($E12=0,HOUR($B12)=COLUMNS($I12:I12)),$B12-J$10,IF(AND($E12=1,HOUR($B12)<COLUMNS($I12:I12)),1/24,"")))
The first and last columns will have to be modified but as this may not be what you want I won't do any more now. Again - NOT FULLY TESTED
Bookmarks