MS Access: Weekday Function
Learn how to use the Access Weekday function with syntax and examples.
The Microsoft Access Weekday function returns a number representing the day of the week (a number from 1 to 7) given a date value.
The syntax for the Microsoft Access Weekday function is:
Weekday ( date_value, [firstdayofweek] )
Parameters or Arguments
date_value is a valid date.
firstdayofweek is optional. It determines what day is to be the first day of the week. It can be any of the following values:
|vbUseSystem||0||Use the NLS API settings|
|vbSunday||1||Sunday (default used)|
If this parameter is omitted, the Weekday function assumes that the first day of the week is Sunday.
Please note that if you use the Weekday function in a query, you'll have to use the numeric value (ie: 0 to 7) for the firstdayofweek parameter. You can only use the constant equivalent (ie: vbSunday to vbSaturday) in VBA code.
The Weekday function can be used in the following versions of Microsoft Access:
- Access 2013, Access 2010, Access 2007, Access 2003, Access XP, Access 2000
|Weekday (#22/11/2003#)||would return 7|
|Weekday (#22/11/2003#, vbThursday)||would return 3|
|Weekday (#22/11/2003#, 5)||would return 3|
|Weekday (#01/01/1998#)||would return 5|
Example (in VBA Code)
The Weekday function can be used in VBA code in Microsoft Access. For example:
Dim LWeekday As Integer LWeekday = Weekday(#12/03/2001#, vbSunday)
In this example, the variable called LWeekday would now contain the value of 2.
Example (in SQL/Queries)
You can also use the Weekday function in a query in Microsoft Access.