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
July 25, 2006 was a Tuesday. With the default Sunday-first numbering, Sunday is 1, Monday is 2 and Tuesday is 3.
Weekday(date[, firstdayofweek])
The date argument is required. The optional firstdayofweek sets which day receives number 1; vbSunday is the usual default.
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)
%>
| Number | Day |
|---|---|
| 1 | Sunday |
| 2 | Monday |
| 3 | Tuesday |
| 4 | Wednesday |
| 5 | Thursday |
| 6 | Friday |
| 7 | Saturday |
WeekdayName(weekday[, abbreviate[, firstdayofweek]])
The weekday argument is 1–7, interpreted relative to firstdayofweek. Set abbreviate to True for a shorter name.
<%
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.
<%
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.
<%
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.
<%
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.
<%
Dim dayNo
For dayNo = 1 To 7
Response.Write dayNo & ": " & WeekdayName(dayNo) & "<br>"
Next
%>
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.
Sunday is day 1 by default, so Tuesday is day 3.
Use Weekday(myDate, vbMonday) and pass vbMonday to WeekdayName() too.
Yes. Pass True as the second argument to WeekdayName().
Use Day(myDate) or DatePart("d", myDate).
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.