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:eek:o:eek:o), 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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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,215,343
Messages
6,124,405
Members
449,157
Latest member
mytux

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