Difference between times over midnight

ISlo

New Member
Joined
Nov 17, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi all - I'm sure I've done this before but can't find the solution which I think lies simply in the formatting. I'm trying to calculate time elapsed which includes values that cross over midnight, but I just can resolve. It just won't return a value - can any help? Format below is [hh]:mm

Thanks

StartEndElapsed
22:30​
23:30​
01:00​
23:30​
00:10​
########​
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Welcome to the forum,

You can use date & time and do the same calculation, if the option to use date as well is not available then maybe the below:
Book1
ABC
1StartEndElapsed
222:3023:3001:00
323:3000:1000:40
Sheet1
Cell Formulas
RangeFormula
C2:C3C2=MOD(B2-A2,1)
 
Upvote 0
Note that the issue is the all valid time entries also have a date component. If you do not explicitly enter the date piece, it defaults to today.
So in your second entry, you are subtracting the 11/17/2023 11:30 PM from 11/17/2023 12:10 AM, which results in a negative value.

You could use a formula like this, that would add one day if the column A entry is larger than the column B entry:
Excel Formula:
=IF(B2>A2,B2-A2,(B2+1)-A2)
or you can use the simpler formula provided by Georgiboy, which gets to the same place by dividing the result by one and taking the remainder.
 
Upvote 0
Welcome to the forum,

You can use date & time and do the same calculation, if the option to use date as well is not available then maybe the below:
Book1
ABC
1StartEndElapsed
222:3023:3001:00
323:3000:1000:40
Sheet1
Cell Formulas
RangeFormula
C2:C3C2=MOD(B2-A2,1)

That's great thank you!!
 
Upvote 0

Forum statistics

Threads
1,215,095
Messages
6,123,072
Members
449,093
Latest member
ripvw

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