Parcial time calculation complex formula

eduzs

Well-known Member
Joined
Jul 6, 2014
Messages
704
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Hi there,

Given a time (fist column START, second column END:

STARTEND"NIGHT TIME" (HOURS)
04:0023:302,5
14:0001:003,0

<tbody>
</tbody>

I need to get the "NIGHT TIME", that is the time not between 05:00 and 22, or, in other words, thats from 0:00 to 5:00, and from 22:00 to 24:00.

In the first example the the formula must return 2,5 hours (1 hour from 4:00 to 5:00 + 1,5 hour from 22:00 to 23:30.

In the second excample the formula must return 3,0 hours (from 22:00 to 01:00).

This is possible by formula?

Need help.

Thanks.
 
Last edited:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
I am working on it for you.
 
Last edited:
Upvote 0
I hope this works. Clock maths is difficult in Excel. I found the answer in this post from years ago; see thread comment #10 http://www.mrexcel.com/forum/excel-...-night-shift-hours-date-time.html#post3847267

ABCDE
1"NIGHT TIME" (HOURS)
2STARTENDclock timeserial numberhours
34:0023:302:300.104172.500
414:001:003:000.125003.000
510:0018:000:000.000000.000
63:0021:302:000.083332.000
712:006:007:000.291677.000
81:0022:004:000.166674.000
94:5922:010:020.001390.033

<colgroup><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet8

Worksheet Formulas
CellFormula
C3=(MOD(B3-A3,1)*24-(B3<A3)*(22-5)+MEDIAN(A3*24,5,22)-MEDIAN(B3*24,5,22))/24
D3=C3
E3=D3*24

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

<strike></strike>
 
Upvote 0
I was unable to solve the question with the above formula, but I found the solution exactly where you told! Great formula in #10, works fine.

For "Night Time" <a3)*(22-5)+med(a3*24;5;22)-med(b3*24;5;22)) 24
=(MOD(B3-A3;1)*24-(B3 < A3)*(22-5)+MED(A3*24;5;22)-MED(B3*24;5;22))/24
<a3)*(22-5)+median(a3*24,5,22)-median(b3*24,5,22)) 24[="" code]
<a3)*(22-5)+median(a3*24,5,22)-median(b3*24,5,22)) 24[="" code]
<a3)*(22-5)+median(a3*24,5,22)-median(b3*24,5,22)) 24
For "Day time" =MOD(B3-A3;1)-C3

Thanks a lot!.</a3)*(22-5)+median(a3*24,5,22)-median(b3*24,5,22))></a3)*(22-5)+median(a3*24,5,22)-median(b3*24,5,22))></a3)*(22-5)+median(a3*24,5,22)-median(b3*24,5,22))></a3)*(22-5)+med(a3*24;5;22)-med(b3*24;5;22))>
 
Last edited:
Upvote 0
Ps.: remove blank space between B3 < A3, also replace ; with ,
MED = MEDIAN

Now I'm think about a way to show in "hours" not in time.

Found easily, just removed "/24"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,574
Messages
6,131,496
Members
449,653
Latest member
aurelius33

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