Name
WeekdayName Function
Class
Microsoft.VisualBasic.DateAndTime
Syntax
WeekdayName(Weekday, [abbreviate [, FirstDayOfWeekValue]]
)
-
Weekday
Use: Required
Data Type: Long
The ordinal number of the required weekday, from 1 to 7
-
abbreviate
Use: Optional
Data Type: Boolean
Specifies whether to return the full day name or an abbreviation
-
FirstDayOfWeekValue
Use: Optional
Data Type:
FirstDayOfWeek
constantMember of the
FirstDayOfWeek
enum indicating the first day of the week
Return Value
A String
Description
Returns the name of the day
Rules at a Glance
Weekday
must be a number between 1 and 7, or the function generates an ArgumentException error.The default value of
abbreviate
isFalse
.For a list of the members of the FirstDayOfWeek enumeration, see the “Weekday Function” entry.
The default value of
FirstDayOfWeekValue
isFirstDayOfWeek.Monday
.
Programming Tips and Gotchas
Since
Weekday
is an integer, to determine the name of the day of a particular date, combineWeekDayName
with a call to theWeekDay
function, as the following code fragment shows:sDay = WeekDayName(Weekday(dDate, iFirstDay), _ bFullName, iFirstDay)
Note that the value of the
FirstDayOfWeek
argument must be the same in the calls to both functions forWeekdayName
to return an accurate result.Unlike the
Weekday
function, theWeekdayName
function behaves predictably. For example, if you ask for the name of the first day of the week when the week starts on Monday, the function returnsMon
orMonday
. If you ask for the fifth day ...
Get VB .NET Language in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.