Calculating time differences regardless of date

gruntingmonkey

Active Member
Joined
Mar 6, 2008
Messages
434
Office Version
  1. 365
Platform
  1. Windows
I am trying to calculate in minutes how far two times are apart regardless of what day it is. In the image attached, I cant work out the calculation for column C. In theory, the minutes difference will never be more than 720 (12 hours times 60 minutes).
Actual TimeGuessed TimeMinutes difference
23:5900:012
01:0162
02:01122
12:00719
18:00359
 

Attachments

  • Capture.PNG
    Capture.PNG
    5 KB · Views: 11

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.
will the time always be clockwise the time in A1 - ie clockwise on a clock

for example - if it was 20:00 - then if a guess was
20:01 = thats 1 min
07:59 - then 718
and will never be later than 08:01 ????

so can never be
20:01
19:59
 
Upvote 0
will the time always be clockwise the time in A1 - ie clockwise on a clock

for example - if it was 20:00 - then if a guess was
20:01 = thats 1 min
07:59 - then 718
and will never be later than 08:01 ????

so can never be
20:01
19:59
No - the time won't always be one way. It's a guessing game. Guess the closest time. So you can guess any time in 24 hours. In your example, if the time was 20:00 then a guess of either 20:01 or 19:59 would both be 1 minute out.
 
Upvote 0
a guess; parts of the information are not clear

Time.xlsm
ABCDE
1
223:5900:0100:0222
301:0101:026262
402:0102:02122122
512:0012:01721720
618:0018:011081720
7
12a
Cell Formulas
RangeFormula
C2:C6C2=B2-$A$2+($A$2>B2)
D2:D6D2=C2*24*60
E2:E6E2=MIN(720,C2*24*60)
The bottom two rows don't show the correct result. Its not a case of a minimum of 720. In terms of time it's how far away the times are apart from that original ctual time. It will never be more than 12 hours (720 minutes). Apologies, I'm not sure if I'm explaining it appropriately.

It's a guessing game. Guess the closest time. So you can guess any time in 24 hours. In your example, if the time was 20:00 then a guess of either 20:01 or 19:59 would both be 1 minute out.
 
Upvote 0
try this: =MIN(A2-B2,(1+A2-B2)) where A2 has the initial value and B2 the guess. It assumes that the cells are formatted for times and contain times (ie no date element).

HTH.
 
Upvote 0
try this: =MIN(A2-B2,(1+A2-B2)) where A2 has the initial value and B2 the guess. It assumes that the cells are formatted for times and contain times (ie no date element).

HTH.
Thanks for looking into for me. It doesn't appear to give the result I'm after though.
Actual TimeGuessed TimeMinutes differencePJMorris
23:5900:012
23:58:00​
01:0162
22:58:00​
02:01122
21:58:00​
12:00719
11:59:00​
18:00359
05:59:00​


I have found a solution though using @Dave Patton solution though using his calculations in column C & D.
Everything over 720 is removed the sum and therefore kind of counts backwards. I'm sure there must be a simpler calculation but I'm just happy I found something that works!

=SUM(720-ABS(720-SUM(SUM(B2-$A$2+($A$2>B2))*24*60)))
 
Upvote 0
Solution
Hi, apologies. The correct formula is =MIN($A$1-B1,(1+B1-$A$1)) and you need a custom format of [m] to show the total number of minutes. Alternatively and to more easily use the number of minutes in a calculation format the cell as 'general' which is the default and use =MIN($A$1-B1,(1+B1-$A$1))*24*60.

That said, there is usually more than one way of solving the problem.

Regards
 
Upvote 0
Do you require so many "Sum" functions?
Consider =720-ABS(720-(B2-$A$2+($A$2>B2))*24*60)
or =MIN($A$2-B6,B6-$A$2+($A$2>B6))*24*60

With Excel 365
=LET(x,(B2-$A$2+($A$2>B2))*24*60,IF(x<=720,x,720-(x-720)))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,942
Messages
6,122,366
Members
449,080
Latest member
Armadillos

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