Compare DayOfWeek

Hi Experts,

Having problem compare the day of the week

Dim strDayOfWeek = "Monday"

IF Now.DayOfWeek = strDayOfWeek THEN <-- HOw to compare?

END IF

Can you please help?

TIA!
LVL 5
allanau20Asked:
Who is Participating?
 
craskinConnect With a Mentor Commented:
just use Now.DayOfWeek.ToString

without the ToString, it just returns a number from 0 to 6.
0
 
steveberzinsCommented:
DayOfWeek is an enumeration...

so this would work

If DateTime.Now.DayOfWeek = DayOfWeek.Monday Then
0
 
drekowConnect With a Mentor Commented:
if now.dayofweek.tostring = strdayofweek then
     'do something here
end if

i would also convert them both to toupper to be on the safe side

if now.dayofweek.tostring.toupper = strdayofweek.toupper then
     'do something here
end if

Hope that helps

Dale
0
 
allanau20Author Commented:
Ahh, yes I was looking for the .toString. Thanks.
I'll split the points.
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.