Weekday
The Weekday function calculates the day of the week for
any given date. The only required parameter is a Date
or Datetime expression that the function should return
the day of the week for. The day of the week ranges from 1
to seven and corresponds to the following values:
| Constant |
Value |
Meaning |
| vbSunday |
1 |
Sunday |
| vbMonday |
2 |
Monday |
| vbTuesday |
3 |
Tuesday |
| vbWednesday |
4 |
Wednesday |
| vbThursday |
5 |
Thursday |
| vbFriday |
6 |
Friday |
| vbSaturday |
7 |
Saturday |
The second parameter is an optional parameter which indicates which
day of the week you are using as the first day of the week. Be default,
the function will use Sunday as the first day of the week.
Dim dDate dDate = Now() ' build the weekday based on the default setting
Response.Write "Weekday is: " & Weekday(dDate) & "<BR>" Response.Write "Weekday Name is: " & WeekdayName(Weekday(dDate)) & "<BR>"
' build the weekday based on first day of monday
Response.Write "Weekday is: " & Weekday(dDate, vbMonday) & "<BR>" Response.Write "Weekday Name is: " & WeekdayName(Weekday(dDate, vbMonday)) & "<BR>"
This method is very useful for displaying the current day-of-the-week and
also for building a calendar application. You can retrieve individual parts of
a date using the Year, Month and Day functions as well
as the DatePart function.
|
 |

|