# IF AND Time Range Comparison

#### barnetod

##### New Member
First post so bare with me.

I am attempting to create a formula which will indicate with a simple YES or NO based on a time value falling between two different times daily.

I have searched and attempted formulas but it seems to just lock into returning NO every time.

If the time is >1700 or <0700 return YES if not return NO.<time(7,0,0),g2 TIME(17,0,0)),?YES?,?NO?)<time(7,0,0),g2="">

=IF(AND(G2<TIME(7,0,0),G2>TIME(17,0,0)),"YES","NO")

Please not for some reason half of my formula is missing.<time(7,0,0),g2><time(7,0,0),g2><time(7,0,0),g2><time(7,0,0),g2>

</time(7,0,0),g2></time(7,0,0),g2>I may be missing an OR statement.

Any help would be appreciated.
 After Hours Time YES 06:37:00 NO 12:30:00

<tbody>
</tbody>
</time(7,0,0),g2></time(7,0,0),g2></time(7,0,0),g2>

Last edited:

### Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Your words "If the time is >1700 or <0700 return YES if not return NO." are the opposit of the example you gave at the end. The formula below assumes the time is in cell A1 and it is based on the "words" - if you want it based on the examples, switch the < and > signs:

Code:
``=IF(OR(A1 > TIME(17,0,0),A1 < TIME(7,0,0)),"Yes","No")<time(7,0,0)),"yes","no")<time(7,0,0)),"yes","no")< html="">``
</time(7,0,0)),"yes","no")<time(7,0,0)),"yes","no")<>

Thank you it worked perfectly. I have been staring at 1800 lines of data and this one thing killed my brain.

Replies
3
Views
336
Replies
2
Views
344
Replies
6
Views
280
Replies
8
Views
449
Replies
5
Views
520

1,207,387
Messages
6,078,197
Members
446,320
Latest member
vatra

### 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.

### Which adblocker are you using?

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

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