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:
  • 0: Uses the regional setting.
  • 1: Sunday (default)
  • 2: Monday
  • 3: Tuesday
  • 4: Wednesday
  • 5: Thursday
  • 6: Friday
  • 7: Saturday

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)
      

**Note:** The output for the second and third examples will vary depending on the current date and your system's regional settings for the first day of the week. The numbers 1-7 represent Sunday through Saturday, but the mapping depends on the `firstdayofweek` parameter.