VBScript WeekDayName function



VBScript WeekDayName

VBScript WeekDayName() function will return the name of the Weekday for the specified day.

Syntax :

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

Parameter Description :

ParameterExplanation
weekdaya Required Parameter. The number of the weekday
toabbreviateAn Optional Parameter. A Boolean value Boolean value that indicates if the month name is to be abbreviated. If left blank then the default value would be taken as False.
firstdayofweekAn Optional Parameter. Specifies the first day of the week.

Below is list of the constants defined in VBScript for value of week days -

CodeConstant NameValue
0vbUseSystemDayOfWeekUse National Language Support (NLS) API setting
1vbSundaySunday
2vbMondayMonday
3vbTuesdayTuesday
4vbWednesdayWednesday
5vbThursdayThursday
6vbFridayFriday
7vbSaturdaySaturday

Example

<!DOCTYPE html>
<html>
<body>
<script language="vbscript" type="text/vbscript">
document.write("Line 1 : " & WeekdayName(6)) 
document.write("<br />")
document.write("Line 2 : " & WeekdayName(1,True))
document.write("<br />")
document.write("Line 3 : " & WeekdayName(4,False))
document.write("<br />")
document.write("Line 4 : " & WeekdayName(4,True,0))
document.write("<br />")
document.write("Line 5 : " & WeekdayName(2,False,1))
document.write("<br />")
</script>
</body>
</html>

Output :

After running above script in IE we will get following output -

Line 1 : Friday
Line 2 : Sun
Line 3 : Wednesday
Line 4 : Wed
Line 5 : Monday