check time

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

if Datetime.now.hour > 4 and datetime.now.minute>=40  ?
VBdotnet2005Asked:
Who is Participating?
 
Jacques Bourgeois (James Burger)Connect With a Mentor PresidentCommented:
Also :

If Now.TimeOfDay > New TimeSpan(16, 40, 0) Then
0
 
käµfm³d 👽Commented:
if Datetime.now.hour >= 16 and datetime.now.minute>=40

Open in new window

0
 
VBdotnet2005Author 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
 
käµfm³d 👽Connect With a Mentor 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

Open in new window

0
 
VBdotnet2005Author 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.

All Courses

From novice to tech pro — start learning today.