Formula to Split Start/End Times into Hour Brackets

MrMaker

Board Regular
Joined
Jun 7, 2018
Messages
56
Office Version
  1. 365
Platform
  1. Windows
Good Morning,

I have a set of data with start/end dates which I am trying to split into hour categories so I can dissect further (i.e if a line starts at 5am and ends at 7am I would expect to see 1 hour in the 5 and 6 am columns)
My formula splits things up nicely but when the end date falls in the next day it still includes it with the same line (see highlighted yellow line).
Is there a solution that anyone knows or can suggest that I have overlooked?

The generic formula I found on here to split the hours up is this:

Excel Formula:
    =(NETWORKDAYS(B5,C5)-1)*($G$3-$G$2)
+IF(NETWORKDAYS(C5,C5),MEDIAN(MOD(C5,1),$G$3,$G$2),$G$3)
-MEDIAN(NETWORKDAYS(B5,B5)*MOD(B5,1),$G$3,$G$2)

Many thanks
 

Attachments

  • Capture.JPG
    Capture.JPG
    135.8 KB · Views: 13

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
What is does currently makes perfect sense to me. The correct times fall under the correct hours on the same row that your start/end times appear. It wouldn't make any sense to me to show it on any other row. How do you want this to appear instead?
 
Upvote 0
Hi Jeff,

Not a great explanation from myself, apologies.

Essentially, I was looking for a daily summary view of the data, i.e only calculating the hours from 00:00 until 23:59 of the start date (08/07/24) ......with the 00:00 to 06:31 (09/07/24) somehow being represented on a daily summary for 09/07/24.

95% of the data has the same start and end date, it's just the 5% that skews things from a daily summary point of view.

I'm beginning to think it's probably not doable without major manual intervention.

Thanks
 
Upvote 0
How are you getting a daily summary when each block of time appears on its own row? That is, there are multiple rows for each day. I don't see a summary per day in your screenshot. Do you need the detail of hours broken out for each set of times, or just the totals per day?

I'm sure this can all be done automatically but you would probably need a redesign. Something like this layout, but I haven't worked out formulas.

$scratch.xlsm
AB
1StartEnd
27/8/2024 15:007/8/2024 16:30
37/8/2024 15:007/8/2024 16:30
47/8/2024 15:007/8/2024 16:30
57/8/2024 15:007/8/2024 16:30
67/8/2024 15:007/8/2024 16:30
77/8/2024 15:007/9/2024 06:30
87/9/2024 06:307/9/2024 07:30
97/9/2024 06:307/9/2024 07:30
107/9/2024 06:307/9/2024 07:30
Sheet9


$scratch.xlsm
DEFGHIJKLMNOPQRSTUVWXYZAAAB
1Date00:00:0001:00:0002:00:0003:00:0004:00:0005:00:0006:00:0007:00:0008:00:0009:00:0010:00:0011:00:0012:00:0013:00:0014:00:0015:00:0016:00:0017:00:0018:00:0019:00:0020:00:0021:00:0022:00:0023:00:00
27/8/202406:00:0003:30:0001:00:0001:00:0001:00:0001:00:0001:00:0001:00:0001:00:00
37/9/202400:30:0000:30:00
Sheet9
Cell Formulas
RangeFormula
F1:AB1F1=E1+(TIME(1,0,0))
 
Upvote 0
Could you explain what the end result you need is? Maybe there is another way.
 
Upvote 0

Forum statistics

Threads
1,223,879
Messages
6,175,148
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top