Excel Using Greater than less than with time

mathomas45

New Member
Joined
Mar 5, 2018
Messages
3
[FONT=&quot]Hello - [/FONT]

[FONT=&quot]I have a situation which requires me to isolate three separate time periods and return different results.[/FONT]

[FONT=&quot]If the time is >= Midnight (oo:oo:oo), but less than 8:00 AM - I need to return the result "Midnight"[/FONT]
[FONT=&quot]If the time is >= 8:00 AM, but less than 16:00 (4:00 PM) - I need to return the result "Day"[/FONT]
[FONT=&quot]If the time is >=16:00, but less than midnight (00:00:00) - I need to return the result "Afternoon"[/FONT]

[FONT=&quot]I tried the following formula, but I get the "Problem with this formula" error message from Excel[/FONT]

[FONT=&quot]=IF(AND(F3>=TIME(0,0,0);F3<TIME(8,0,0),"Midnight",IF(AND(F3>=TIME(16,0,0);F3<TIME(0,0,0),"Afternoon","Day"))))[/FONT]

[FONT=&quot]Any suggestions from all you Excel guru's out there.....[/FONT]
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
actually... this is my formula..

=IF(AND(F3>=TIME(0,0,0);F3<TIME(8,0,0),"Midnight",IF(AND(F3>=TIME(16,0,0);F3<TIME(0,0,0),"Afternoon","Day"))))
 
Upvote 0
IF(MOD(F3,1) < TIME(8,0,0),"midnight",IF(MOD(F3,1) < TIME(16,0,0),"Day","Afternoon")

The MOD is there to handle date/time figures.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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