Reverse weekdayname function?

  • Thread starter Thread starter Vin Antonello
  • Start date Start date
V

Vin Antonello

I have a table where the person inputs a deadline day (as monday, thursday,
etc...) and a deadline time (11, 15, 17, etc....).

What i need is a code that transforms this "monday" value to a value that i
can compare with my Weekday(Now, vbThursday) code!

Thanks in advance
 
Since there are only 7 days, you can write straightforward code:
If weekday(vbSunday) = MyDateString Then
longDayNumber = vbSunday
ElseIf weekday(vbMonday) = MyDateString Then
longDayNumber = vbMonday
....
Else
msgbox "User entered something other than an 'official' day name"
End If

If you want to accept more variations of the day name, you could have a
table of day name strings with the day number.

Or you could prevent the issue by giving the user a dropdown list to choose
the day. This would be my choice. Free text is evil, to be avoided whenever
possible!
 
I think you meant to use the WeekdayName function, not the Weekday function.
 
Back
Top