totn Access Functions

MS Access: WeekdayName Function

This MSAccess tutorial explains how to use the Access WeekdayName function with syntax and examples.

Description

The Microsoft Access WeekdayName function returns a string representing the day of the week given a number from 1 to 7.

Syntax

The syntax for the WeekdayName function in MS Access is:

WeekdayName ( number, [abbreviate], [firstdayofweek] )

Parameters or Arguments

number
A value from 1 to 7, representing a day of the week.
abbreviate
Optional. This parameter accepts a boolean value, either TRUE or FALSE. If this parameter is set to TRUE, it means that the weekday name is abbreviated. If this parameter is set to FALSE, the weekday name is not abbreviated.
firstdayofweek

Optional. It determines what day is to be the first day of the week. If this parameter is omitted, the Weekday function assumes that the first day of the week is Sunday. It can be any of the following values:

Constant Value Explanation
vbUseSystem 0 Use the NLS API settings
vbSunday 1 Sunday (default used)
vbMonday 2 Monday
vbTuesday 3 Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday

Returns

The WeekdayName function returns a string value.

Note

  • If you use the WeekdayName 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.

Applies To

The WeekdayName function can be used in the following versions of Microsoft Access:

  • Access 2019, Access 2016, Access 2013, Access 2010, Access 2007, Access 2003, Access XP, Access 2000

Example

Let's look at how to use the WeekdayName function in MS Access:

WeekdayName (3)
Result: 'Tuesday'

WeekdayName (3, TRUE)
Result: 'Tue'

WeekdayName (3, TRUE, vbMonday)
Result: 'Wed'

WeekdayName (3, TRUE, 2)
Result: 'Wed'

Example in VBA Code

The WeekdayName function can be used in VBA code in Microsoft Access.

For example:

Dim LValue As String

LValue = WeekdayName (3, TRUE, vbMonday)

In this example, the variable called LValue would now contain the value of 'Wed'.

Example in SQL/Queries

You can also use the WeekdayName function in a query in Microsoft Access.

For example:

Microsoft Access

In this query, we have used the WeekdayName function as follows:

Expr1: WeekdayName(3,True,2)

This query will return the abbreviated weekday name for the value 3, where the first day of the week is Monday (as specified by 2 as the final parameter). The results will be displayed in a column called Expr1. You can replace Expr1 with a column name that is more meaningful.

For example:

WeekdayValue: WeekdayName(3,True,2)

The results would now be displayed in a column called WeekdayValue.