Weekday() and WeekdayName() in Classic ASP

Weekday() returns a number from 1 to 7 for a date, while WeekdayName() returns the corresponding localized day name. The mapping depends on the chosen first day of the week.

<%
Dim myDate
myDate = DateSerial(2006, 7, 25)
Response.Write Weekday(myDate) & "<br>"
Response.Write WeekdayName(Weekday(myDate))
%>
3
Tuesday
On this page — Show page sectionsHide page sections

July 25, 2006 was a Tuesday. With the default Sunday-first numbering, Sunday is 1, Monday is 2 and Tuesday is 3.

Weekday() syntax

Weekday(date[, firstdayofweek])

The date argument is required. The optional firstdayofweek sets which day receives number 1; vbSunday is the usual default.

Original fixed date example

Weekday(#7/25/2006#)

Result: 3 with Sunday-first numbering. You can also pass an existing Date variable:

<%
Dim d_mydate
d_mydate = DateSerial(2006, 7, 25)
Response.Write Weekday(d_mydate)
%>

Default Weekday() numbers

NumberDay
1Sunday
2Monday
3Tuesday
4Wednesday
5Thursday
6Friday
7Saturday

WeekdayName() syntax

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

The weekday argument is 1–7, interpreted relative to firstdayofweek. Set abbreviate to True for a shorter name.

Full and abbreviated weekday names

<%
Response.Write WeekdayName(4) & "<br>"
Response.Write WeekdayName(4, True) & "<br>"
Response.Write WeekdayName(5, False)
%>
Wednesday
Wed
Thursday

These English names match the original examples. Actual returned strings depend on the ASP locale.

Get the current weekday

<%
Dim d_mydate
d_mydate = Now
Response.Write WeekdayName(Weekday(d_mydate))
%>

The result varies with the current server date. Now includes time; Date is sufficient when you need only the day.

Change the first day to Monday

<%
Dim myDate
myDate = DateSerial(2006, 7, 25)
Response.Write Weekday(myDate, vbMonday) & "<br>"
Response.Write WeekdayName(Weekday(myDate, vbMonday), False, vbMonday)
%>
2
Tuesday

Pass the same vbMonday setting to both functions to keep their weekday numbers and names consistent.

Check whether a date falls on a weekend

<%
Dim myDate, weekdayNo
myDate = DateSerial(2026, 11, 14)
weekdayNo = Weekday(myDate, vbMonday)
If weekdayNo >= 6 Then
  Response.Write "Weekend"
Else
  Response.Write "Weekday"
End If
%>
Weekend

This example assumes Saturday and Sunday are the weekend. Holiday and working-day rules differ across organizations and regions.

Display weekday names for one full week

<%
Dim dayNo
For dayNo = 1 To 7
  Response.Write dayNo & ": " & WeekdayName(dayNo) & "<br>"
Next
%>

Common mistakes

A weekday number is not the same as the date’s day-of-month. Use Day(myDate) for the day of the month, Weekday(myDate) for the day of the week, and DatePart("ww", myDate) for the week number.

Frequently asked questions

Why does Tuesday return 3 by default?

Sunday is day 1 by default, so Tuesday is day 3.

How can I make Monday day 1?

Use Weekday(myDate, vbMonday) and pass vbMonday to WeekdayName() too.

Can I display a short day name such as Tue?

Yes. Pass True as the second argument to WeekdayName().

How do I extract the day of the month?

Use Day(myDate) or DatePart("d", myDate).

Back to top ↑


ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer