This article mainly introduces the method of getting the day of the week in asp. It mainly uses the application of weekday function and weekdayname function. Friends who need it can refer to it.
The test code is as follows, please use IE to run this example
Copy the code code as follows:<script language=vbscript>
d=now
xqj=weekday(d)
msgbox xqj' outputs numbers, Sunday is 1, Monday is 2...and so on, Saturday is 7
msgbox weekdayname(xqj)
</script>
WEEKDAY Purpose: Returns the week number of a certain date. By default, its value is an integer between 1 (Sunday) and 7 (Saturday).
Weekday is a function in Visual Basic and VBS that returns an integer representing a day of the week.
grammar
Copy the code code as follows: Dim xx=Weekday(date[,FirstdayOfWeek])
parameter
The syntax of the Weekday function has the following parameters:
parameter | describe |
date | Required. Any expression that can represent a date. If the date parameter contains Null, then Null is returned |
FirstdayOfWeek | Optional. A constant that specifies the first day of the week. If omitted, vbSunday is used by default |
Parameter setting value
The FirstdayOfWeek parameters have the following settings:
constant | value | describe |
vbUseSystem | 0 | Using the Regional Language Support (NLS) API settings |
vbSunday | 1 | Sunday |
vbMonday | 2 | Monday |
vbTuesday | 3 | Tuesday |
vbWednesday | 4 | Wednesday |
vbThursday | 5 | Thursday |
vbFriday | 6 | Friday |
vbSaturday | 7 | Saturday |
The Weekday function returns the following values:
constant | value | describe |
vbSunday | 1 | Sunday |
vbMonday | 2 | Monday |
vbTuesday | 3 | Tuesday |
vbWednesday | 4 | Wednesday |
vbThursday | 5 | Thursday |
vbFriday | 6 | Friday |
vbSaturday | 7 | Saturday |
WeekdayName is used to return a string representing a day of the week.
grammar
WeekdayName(weekday, abbreviate, firstdayofweek)
The WeekdayName function syntax has the following parts:
weekday Required. A numeric value representing the day of the week. The numerical value depends on the setting value in the firstdayofweek setting.
abbreviate Optional. Boolean value indicating whether the name of the week is abbreviated. If this value is omitted, the default value is False, indicating that day of the week names cannot be abbreviated.
firstdayofweek Optional. A numeric value representing the first day of the week. For its value, see the Setting Values section.
The firstdayofweek parameter values are as follows:
Constant value description
vbUseSystem 0 uses the National Language Support (NLS) API to set the value.
vbSunday 1 Sunday (default).
vbMonday 2 Monday
vbTuesday 3 Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday