Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IF statement using TIME

I am trying to write an IF statement to look at a range for time and return either Shift A or Shift B.

This is my formula that isn't working:

=IF(F2>TIME(6,0,0),IF(F2<TIME(16,0,0)),"A","B")
like image 294
ajaustin12 Avatar asked Mar 13 '26 20:03

ajaustin12


1 Answers

Use =AND where both (or more) conditions have to be met to result in TRUE. Then the second IF is not required. With:

=IF(AND(F2>TIME(6,0,0),F2<TIME(16,0,0)),"A","B")  

Shift A applies to just after 06:00 hrs through to just before 16:00 hrs and Shift B otherwise. IF and F so intermingled in the same formula was a little unfortunate!

like image 188
pnuts Avatar answered Mar 16 '26 11:03

pnuts



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!