# check time

How can I check if the time is past 4:40pm?

if Datetime.now.hour > 4 and datetime.now.minute>=40  ?
###### Who is Participating?

PresidentCommented:
Also :

If Now.TimeOfDay > New TimeSpan(16, 40, 0) Then
0

Commented:
``````if Datetime.now.hour >= 16 and datetime.now.minute>=40
``````
0

Author Commented:
Is this right?
if Datetime.now.hour >= 16 and datetime.now.minute>=40

what if the hr is 20 and min is 30?

Datetime.now.hour >= 16  would be true and datetime.now.minute>=40 would be false.

I just want to know if the time has past 16:40.
0

Commented:
Ah. Good point. James' suggestion would probably be better (in terms of succinctness), but to correct:

``````if (Datetime.now.hour >= 16 andalso datetime.now.minute>=40) OrElse DateTime.Now.Hour > 16 Then
``````
0

Author Commented:
Thank you again
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.