Home » VBA-Functions » VBA-Weekday-Function

# The VBA Weekday Function

Related Function:

VBA WeekdayName## Description

The VBA Weekday Function returns an integer (from 1 to 7), representing the day of the week for a supplied date.

The syntax of the function is:

Weekday( Date, [FirstDayOfWeek] )

Where the function arguments are:

Date | - | The date that you want to return the weekday of. |

[FirstDayOfWeek] | - | An optional FirstDayOfWeek enumeration value, specifying the weekday that should be used as the first day of the week. This can have any of the following values: vbUseSystemDayOfWeek | - | The first day of the week is as specified in your system settings | vbSunday | - | Sunday | vbMonday | - | Monday | vbTuesday | - | Tuesday | vbWednesday | - | Wednesday | vbThursday | - | Thursday | vbFriday | - | Friday | vbSaturday | - | Saturday |
If omitted, the [FirstDayOfWeek] argument uses the default value **vbSunday**. |

## VBA Weekday Function Examples

The following examples use the VBA Weekday function to return the day of week for the date 12/31/2015 (a Thursday).

### Example 1

Dim wkday As Integer wkday = Weekday( #12/31/2015# ) |

Note that, in the above call to the Weekday function, the [FirstDayOfWeek] argument is omitted and so it uses the default value **vbSunday**. Therefore, 12/31/2015 (a Thursday) relates to weekday number *5*.

### Example 2

Dim wkday As Integer wkday = Weekday( #12/31/2015#, vbThursday ) |

Note that, in the above call to the VBA Weekday function, the [FirstDayOfWeek] argument is set to the value **vbThursday**. Therefore, 12/31/2015 (a Thursday) relates to weekday number *1*.

## VBA Weekday Function Error

If the Date argument that is supplied to the Weekday function cannot be interpreted as a valid date, the function returns the error:

Run-time error '13': Type mismatch