[RESOLVED] WeekdayName -> Date.DayOfWeek vs Weekday() different
Dt = 7/16/2013 Tuesday....
Dim DN As String = WeekdayName(Weekday(dT))
DN = Tuesday
Dim DN As String = WeekdayName(dT.DayOfWeek)
DN=Monday
Any clue why?
Re: WeekdayName -> Date.DayOfWeek vs Weekday() different
dT.DayOfWeek should already return the weekday name, but since you are using it as a parameter it passes the integer value to WeekdayName, which has a different set of indexes than DayOfWeek. DayOfWeek integer values are 0 - 6, which represent the days of the week, while WeekdayName is 0 - 7, with 0 being a flag for the system first day of the week.
http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx
http://msdn.microsoft.com/en-us/libr...dayofweek.aspx
edit: Sorry I read it wrong, it does return an integer, but the indexes are still different. The first example you listed should be the correct way
Re: WeekdayName -> Date.DayOfWeek vs Weekday() different
ahhh!!! i missed that!!! DayOfWeek is 0-6
bingo!
thank you! was driving me nuts! lol
Re: [RESOLVED] WeekdayName -> Date.DayOfWeek vs Weekday() different
You do not need to use WeekdayName.
Code:
Dim DN As String = Dt.DayOfWeek.ToString