Formula for minutes early and late before and after midnight.

Jingles_88

New Member
Joined
Feb 7, 2016
Messages
6
Hi,


I have been working on a spreadsheet which displays the minutes a vehicle if early or late on site. My problem however is that some of the arrivals happen after midnight (00:00); and the formulas i have been using work for wither before or after, not both.


Scheduled On SiteOn SiteOn Site Variance
23:37
23:30
01:20
02:05

<tbody>
</tbody>





I have used the below formula that i found in another forum:
=IF(B2<A2,(B2+1)-(A2),(B2-A2))


The only issue is when the vehicle is early and before midnight the time is incorrect. If i remove the +1 in (B2+1), that issue is solved, but it no longer calculates passed midnight times.


I was wondering if there's a formula that is able to do both. Also, is there a way in which a value doesn't appear in the "On Site Variance" column until a time is entered into the corresponding cell in the "On Site" column.


Any help is greatly welcomed, i have stuck on this for some time.


Many Thanks,


John.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Sorry, i thought i had an attached file. The formula i am using is =IF(B23 < A23,(B23+1)-(A23),(B23-A23))
 
Upvote 0
So I understand that 15 minutes early or late should return 0:15 in either case.

In that case, try
Code:
=IF(B23="","",ABS((MOD(B23-A23,1)>0.5)-MOD(B23-A23,1)))
 
Upvote 0
Hi Marcel,

That has worked perfectly! :).

However it appears that my conditional formatting doesn't work now though. I don't suppose you could assist with that could you? I need it to appear red if late and black if early. If we can go one further, i then need a formula that will return a late or early result based on the time.

I know this seems like a tall order, but every bit of help is greatly appreciated.

Thanks again,

John.
 
Upvote 0
Conditional format formula returns TRUE for late:
Code:
=AND(B23<>"",0>((MOD(B23-A23,1)>0.5)-MOD(B23-A23,1)))
 
Last edited:
Upvote 0
[SOLVED] Formula for minutes early and late before and after midnight.

For the time being all my issues have been solved.

A Million Thank You's to Marcel for helping me.

Thanks,

John.
 
Upvote 0
Re: [SOLVED] Formula for minutes early and late before and after midnight.

You're welcome. :cool:
 
Upvote 0
Re: [SOLVED] Formula for minutes early and late before and after midnight.

Hi Marcel,

Another quick question.

That formula for TRUE and FALSE, is there anyway i can change the text to read LATE and EARLY?

John.
 
Upvote 0
Re: [SOLVED] Formula for minutes early and late before and after midnight.

That would be (with a blank for exactly on time):
Code:
=IF(OR(B23="",A23=B23),"",IF(0>((MOD(B23-A23,1)>0.5)-MOD(B23-A23,1)),"LATE","EARLY")
 
Upvote 0

Forum statistics

Threads
1,216,503
Messages
6,131,022
Members
449,616
Latest member
PsychoCube

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