VBScript Weekday Function

Definition and Usage

The Weekday function can return a number representing the day of the week, ranging from 1 to 7.

Note:

Syntax

Weekday(date[,firstdayofweek])
Parameter Description
date Required. The date expression to be calculated.
firstdayofweek

Optional. Specifies the first day of the week.

The following values can be used:

  • 0 = vbUseSystemDayOfWeek - Use the NLS API set by the regional language support.
  • 1 = vbSunday - Sunday (default)
  • 2 = vbMonday - Monday
  • 3 = vbTuesday - Tuesday
  • 4 = vbWednesday - Wednesday
  • 5 = vbThursday - Thursday
  • 6 = vbFriday - Friday
  • 7 = vbSaturday - Saturday

Instance

Example 1

D = #10/1/2007#
document.write(Weekday(D)) 'October 1, 2007 was a Monday, the second day of the week.'

Output:

2