Weekday Function


Weekday Function

Class

Microsoft.VisualBasic.DateAndTime

Syntax

     Dim result As Integer = Weekday(dateValue[, dayOfWeek]) 


dateValue (required; Date)

The source date from which to extract the weekday.


dayOfWeek (optional; FirstDayOfWeek enumeration)

Indicates the first day of the week. One of the following Microsoft.VisualBasic.FirstDayOfWeek enumeration members: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, or System (to use the regional default). If omitted, Sunday is used.

Description

The Weekday function returns a value indicating the day of the week. A value of 1 indicates the first day of the week; 7 is the last day. These numbers are interpreted based on the definition of the first day of the week. By default, Sunday is the first day of the week.

Usage at a Glance

If passing a date literal as dateValue, the Weekday function requires that all four digits of the year be present.

Example

Since the code:

     Weekday(#11/7/2005#, FirstDayOfWeek.Sunday) 

returns 2; the date November 7, 2005 is a Monday.

Version Differences

The named parameters of the function have changed from date and firstDayOfWeek in VB 6 to dateValue and dayOfWeek in .NET respectively.

See Also

DatePart Function, Day Function, WeekdayName Function




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net