VBScript WeekDayName Function


Advertisements

The WeekDayName function returns the name of the Weekday for the specified day.

Syntax

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

Parameter Description

  • weekday, a Required Parameter. The number of the weekday.

  • toabbreviate, an Optional Parameter. A Boolean value Boolean value that indicates if the month name is to be abbreviated. If left blank, the default value would be taken as False.

  • firstdayofweek, an Optional Parameter. Specifies the first day of the week.

    • 0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting

    • 1 = vbSunday - Sunday

    • 2 = vbMonday - Monday

    • 3 = vbTuesday - Tuesday

    • 4 = vbWednesday - Wednesday

    • 5 = vbThursday - Thursday

    • 6 = vbFriday - Friday

    • 7 = vbSaturday - Saturday

Example

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

      </script>
   </body>
</html>

When you save it as .html and execute it in Internet Explorer, then the above script will produce the following result −

Line 1 : Tuesday
Line 2 : Mon
Line 3 : Sunday
Line 4 : Tue
Line 5 : Sunday
vbscript_date.htm
Advertisements