IF Formula for Greater Than or Less Than with Time

pvtjoker77

New Member
Joined
Aug 31, 2015
Messages
13
Office Version
  1. 2016
Platform
  1. Windows
Hello

First off Thank you in advance!

Here is my set up in 1 cell (AG33) I have the current time using the =LastModified(K4) in the cell below it I'm trying write a formula that if the current time is before or = 11:59 AM it returns Good Morning but if the time is after 11:59 AM but before 5:59 PM it returns Good Afternoon and if it is After 5:59 pm or later it returns Good Evening

Here are 2 that I have tried

This first one I put 11:59 AM in cell AG30 and 5:59 PM in Cell AG31 and in cell (AH33) is Good Morning, In Cell (AI33) Good Afternoon, in Cell (AJ33) is Good Evening for the IF formula below

=IF(AG33<=AG30,AH33, IF(AG33<AG31,AI33, IF(AG33>AG31, AJ33, "")))


The second one

=IF(AG33<=TIME(11,59,59),"Good Morning,",IF(AG33>=TIME(12,0,0),"Good Afternoon,",IF(AG33>=TIME(18,0,0),"Good Evening,""0")))

Any help would be appreciated
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Thanks Johnny!! Sorry about that

What is the problem? I can get the 2 formulas to return Good Morning and Good Afternoon but not Good Evening.


What is not working?

With 1st formula for any time after 5:59 PM it will return 0 and need Good Evening ---> First formula =IF(AG33<=AG30,AH33, IF(AG33<ag31,ai33, if(ag33="" style="color: rgb(51, 51, 51); background-color: rgb(250, 250, 250);">AG31, AJ33, "")))

</ag31,ai33,>With 2nd formula for any time after 5:59 PM it will return Good Afternoon and need Good Evening ---> Second formula =IF(AG33<=TIME(11,59,59),"Good Morning,",IF(AG33>=TIME(12,0,0),"Good Afternoon,",IF(AG33>=TIME(18,0,0),"Good Evening,""0")))

Error messages? None

Thanks Again
 
Last edited:
Upvote 0
Got it figured out. Thanks

="Good "&VLOOKUP(MOD(AG33,1),{0,"Morning";0.5,"Afternoon";0.75,"Evening"},2)
 
Upvote 0
You shouldn't need the MOD and LOOKUP should suffice:

="Good " &LOOKUP(AG33,{0,"Morning";0.5,"Afternoon";0.75,"Evening"})
 
Upvote 0
Solution

Forum statistics

Threads
1,215,358
Messages
6,124,487
Members
449,165
Latest member
ChipDude83

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