Setting condition when current time falls betwen two times

shahdelsol

Active Member
Joined
Jul 21, 2009
Messages
276
Office Version
  1. 365
Platform
  1. Windows
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:
Upvote 0
Here's an alternative:
Code:
=IF(AND(MOD(NOW(),1)>=TIMEVALUE("21:00"),MOD(NOW(),1)<=TIMEVALUE("23:59")),TODAY()+1,TODAY())
 
Upvote 0
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"
 
Upvote 0
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())
 
Upvote 0

Forum statistics

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