Calculate hours and minutes between two dates and time showing Early, Late, On Time

Zilla

Board Regular
Joined
Nov 16, 2006
Messages
88
Office Version
  1. 2016
Platform
  1. Windows
I am having problems with trying to find a formula for the results below.
Three columns below A = Expected, B = Actual, C = Diff.
Line one formula in cell C2 =A2-B2 result = 08:44. Which shows the ship time is early.
The problem is line 4,5,6 the time is late but all I see is #########.

What I would like to see is when the Actual Ship Time is earlier then Expected Ship Time and greater then 4 hours (240 min) show column D as "Early"
When Actual ship time is between 0 and 239 min show as On Time
When Actual ship time is later then 90 minutes past Expected Ship Time show as "Late" (IE:line 4, 5, 6 below)

Any help would be appreciated


Expected Ship TimeActual Ship TimeDiff
2022-06-09 18:302022-06-09 9:4608:44
2022-06-09 9:002022-06-09 5:3603:24
2022-06-09 11:002022-06-09 10:2200:38
2022-06-09 8:002022-06-09 8:11#############????
2022-06-09 17:002022-06-09 17:21#############????
2022-06-09 10:002022-06-09 10:27#############????


Book 1 Time sample.xlsx
ABC
1Expected Ship TimeActual Ship TimeDiff
22022-06-09 18:302022-06-09 9:4608:44
32022-06-09 9:002022-06-09 5:3603:24
42022-06-09 11:002022-06-09 10:2200:38
52022-06-09 8:002022-06-09 8:11#############
62022-06-09 17:002022-06-09 17:21#############
72022-06-09 10:002022-06-09 10:27#############
sample
Cell Formulas
RangeFormula
C2:C7C2=A2-B2
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Negative times cannot exist, that's why you have ##### result. The calculation in decimals however is correct.
For the early, on time and late calculation you can use expected shipdates + time (4,0,0) and + time(1,30,0) and compare the actual ship date. Do this Inside an IFS.
 
Upvote 0
How would I correct the #### to actually appear, is that possible?

Would it be possible to provide the IFS?
 
Upvote 0
Based on your sample and my understanding of the given rules
Book1
ABCDEFGHIJK
1Expected Ship TimeActual Ship TimeDiffE/OT/Ldelta in hours (abs value)"late"Early4:00 AM
29/06/2022 18:309/06/2022 9:460,36389Early8:44:00TRUELate1:30 AM
39/06/2022 9:009/06/2022 5:360,14167On time3:24:00TRUEOn time
49/06/2022 11:009/06/2022 10:220,02639On time0:38:00TRUE
59/06/2022 8:009/06/2022 8:11-0,00764On time0:11:00FALSEdifference is smaler then 90 min
69/06/2022 17:009/06/2022 17:21-0,01458On time0:21:00FALSEdifference is smaler then 90 min
79/06/2022 10:009/06/2022 10:27-0,01875On time0:27:00FALSEdifference is smaler then 90 min
Sheet1
Cell Formulas
RangeFormula
D2:D7D2=IFS((B2:B7+J1)<=A2:A7,I1,(A2:A7+J2)<=A2:A7,I2,TRUE,I3)
F2:F7F2=B2:B7<=A2:A7
J1J1=TIME(4,0,0)
J2J2=TIME(0,90,0)
C2:C7C2=A2-B2
E2:E7E2=ABS(C2)
Dynamic array formulas.
 
Upvote 0
Hi GraH

This is great, the only issue I am having is column D I receive the following as a result #NAME?



Book1
ABCDEFGHIJ
1Expected Ship TimeActual Ship TimeDiffE/OT/Ldelta in hours (abs value)"late"Early4:00 AM
26/10/2022 19:006/9/2022 9:521.38056#NAME?9:08TRUELate1:30 AM
36/10/2022 9:006/10/2022 4:030.20625#NAME?4:57TRUEOn Time
46/10/2022 18:306/10/2022 8:060.43333#NAME?10:24TRUE
56/10/2022 9:006/10/2022 4:500.17361#NAME?4:10TRUE
66/10/2022 17:006/8/2022 12:382.18194#NAME?4:22TRUE
76/10/2022 8:006/10/2022 8:10-0.0069#NAME?0:10FALSE
86/10/2022 18:006/10/2022 14:190.15347#NAME?3:41TRUE
96/10/2022 12:006/10/2022 13:39-0.0687#NAME?1:39FALSE
106/10/2022 21:006/10/2022 17:150.15625#NAME?3:45TRUE
116/10/2022 11:006/10/2022 12:31-0.0632#NAME?1:31FALSE
Sheet1
Cell Formulas
RangeFormula
C2:C11C2=A2-B2
D2:D11D2=IFS((B2:B7+J1)<=A2:A7,I1,(A2:A7+J2)<=A2:A7,I2,TRUE,I3)
E2:E11E2=ABS(C2)
F2:F11F2=B2:B7<=A2:A7
J1J1=TIME(4,0,0)
J2J2=TIME(0,90,0)
 
Upvote 0
Could it be you do not have IFS function in your version? What's your excel version?

Excel Formula:
=IF((B4+J3)<=A4,I3,if((A4+J4)<=A4,I4,I5))
 
Upvote 0
Solution
Excel 2016

I tried the second formula and all is good.

I really appreciate you taking the time to provide the formula you saved me so much time.

Thank You
 
Upvote 0
Thank you for the feedback it's working.
To help and learn from each other, that's the purpose of the forum, right? 😀
Do consider to mark my post as solution. Most appreciated.
 
Upvote 0
Excel 2016

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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