Check if time falls between 2 times

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,404
Office Version
  1. 2016
Platform
  1. Windows
I'm having an issue trying to identify if a time falls between 2 times.

I need to know if the time falls between 23:59 and 05:00 - the cell I'm using is formatted as custom "dd/mm/yyyy hh:mm" and the actual cell value is "01/11/2022 00:35". Using this formula the result should be YES, but it's returning NO:

=IF(AND(C2>="23:59",C2<="05:00"),"YES","NO")

Ideally I need this to be achieved by VBA but for now I just need to understand why it isn't producing the correct result - can anyone help me understand?
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Unless you are going down to the seconds does greater than 23:59 actually mean from midnight.
If that is the case something like this should be enough.
Excel Formula:
=IF(MOD(C2,1)<=TIME(5,0,0),"YES","NO")
 
Upvote 0
Solution
Alex you are a life saver, that does exactly what I need - thank you!!
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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