calculating peak time

kalanr

New Member
Joined
Sep 23, 2011
Messages
2
I've got a data series with timestamps. e.g.

change date time elapsed
24/07/2011 16:35:20
26/07/2011 11:09:19 42:33:59
26/07/2011 11:09:27 0:00:08
28/07/2011 19:31:12 56:21:45
28/07/2011 19:31:16 0:00:04
29/07/2011 07:25:03 11:53:47

to calculate the elapsed time between two timestamps is easy enough, but now I'd have to split the elapsed time to two componenets - time elapsed in peak time (6:00 - 22:00), and off-peak time (22:00-6:00). I've been looking around, but found only solutions events happening on the same day.

Any ideas? I'm open to VBA solution as well ;)
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hello kalanr, welcome to MrExcel

I assume that peak time is 06:00 to 22:00 on all seven days of the week?

If your dates are in A2 down, times in B2 down and the total elapsed time in C3 down then try this formula in D3 for 06:00 to 22:00 (peak) hours.

=(A3-A2)*("22:00"-"6:00")+MEDIAN(B3,"6:00","22:00")-MEDIAN(B2,"6:00","22:00")

and clearly the 22:00 to 06:00 hours are all the rest so E3 can be just

=C3-D3

format both of those cells as [h]:mm:ss and copy down the column
 
Upvote 0
Works like a charm. And it's much simpler, than the solution I started to work on. I really need to get some rest. Luckily it's friday.:biggrin:

thanks
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,480
Members
452,915
Latest member
hannnahheileen

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