Hi all,
I am trying to write a little code to analyze the current time when a button on my form is clicked. I need to know if the current time is between 12:00 pm and 6:00 pm, or between 6:01 pm and 12:59 pm.
I am using a variable called TimeOfDay to capture just the hourly info of Now(), and a step-through shows me I am getting the value I want for this (i.e. 1:08.00 PM).
Here’s what I have been trying to do:
I tried using "between" but couldn't get the syntax right, so I borrowed this from another posting, and it's probably obvious to you why it's not working, but any help you can give me will be greatly appreciated.
Thanks,
LM
I am trying to write a little code to analyze the current time when a button on my form is clicked. I need to know if the current time is between 12:00 pm and 6:00 pm, or between 6:01 pm and 12:59 pm.
I am using a variable called TimeOfDay to capture just the hourly info of Now(), and a step-through shows me I am getting the value I want for this (i.e. 1:08.00 PM).
Here’s what I have been trying to do:
Code:
Select Case TimeofDay
Case Is > #12:00:00 PM# < #6:00:00 PM#
Greeting = "Good Afternoon"
Case Is > #6:01:00 PM# < #11:59:00 PM#
Greeting = "Good Evening"
Case Else
End Select
Thanks,
LM