MS Access Weekday() Function
The Weekday()
function in MS Access determines the day of the week for a given date and returns a corresponding numerical value. This is useful for tasks involving weekly scheduling, reporting, or data analysis.
Weekday(): Definition and Usage
Weekday()
takes a date value and optionally a parameter to specify which day should be considered the first day of the week. The function returns an integer from 1 to 7, where the specific day assigned to each number depends on the firstdayofweek
parameter. By default, 1 represents Sunday.
Syntax
Syntax
Weekday(date, firstdayofweek)
Parameter Values
Parameter | Description |
---|---|
date |
The date for which you want to determine the weekday. This is required. |
firstdayofweek (Optional) |
Specifies the first day of the week. Values:
|
Examples
Getting the Weekday Number for a Specific Date
This example gets the weekday number for May 17th, 2017 (assuming Sunday as the first day of the week).
Syntax
SELECT Weekday(#05/17/2017#);
Output
4 (Wednesday, assuming Sunday is 1)
Getting the Weekday Number for Today
This retrieves the weekday number for the current date.
Syntax
SELECT Weekday(Date());
Output
(A number between 1 and 7 representing today's weekday, assuming Sunday is 1)
Getting the Weekday Number with Monday as the First Day
This example sets Monday as the first day of the week and then gets the weekday number for May 17th, 2017.
Syntax
SELECT Weekday(#05/17/2017#, 2);
Output
3 (Wednesday, assuming Monday is 1)