# Setting condition when current time falls betwen two times

#### shahdelsol

##### Active Member
I am trying to set up an IF formula when the current time falls between 21:00 and 23:59. I have used this formula but it is not working. If the current time is between 21:00 and 23:59, I want to get tomorrow's date but if it is passed midnight, I want to get today's date. Can anyone help?

Code:
``=IF(AND(NOW()>="21:00",NOW()<="23:59"),TODAY()+1,TODAY())``

### Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
It's because you're using text rather than time and I think any success would have been coincidental. Here's an alternative:

Code:
``=TODAY()+IF(HOUR(NOW())>=21,1,0)``

For yours to have worked, you'd have to had used TIMEVALUE("21:00") instead of just "21:00"

Last edited:
Here's an alternative:
Code:
``=IF(AND(MOD(NOW(),1)>=TIMEVALUE("21:00"),MOD(NOW(),1)<=TIMEVALUE("23:59")),TODAY()+1,TODAY())``

Thank you for quick response. I will try it tonight.
It's because you're using text rather than time and I think any success would have been coincidental. Here's an alternative:

Code:
``=TODAY()+IF(HOUR(NOW())>=21,1,0)``

For yours to have worked, you'd have to had used TIMEVALUE("21:00") instead of just "21:00"

Thanks to you as well. I will try yours too. I like to keep both formulas.
Here's an alternative:
Code:
``=IF(AND(MOD(NOW(),1)>=TIMEVALUE("21:00"),MOD(NOW(),1)<=TIMEVALUE("23:59")),TODAY()+1,TODAY())``

Thank to you both. It worked very well!

Replies
1
Views
230
Replies
9
Views
406
Replies
0
Views
200
Replies
13
Views
487
Replies
2
Views
136

1,217,386
Messages
6,136,292
Members
450,002
Latest member
bybynhoc

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