VBScript WeekDay Function


Advertisements

The WeekDay function returns an integer from 1 to 7 that represents the day of the week for the specified date.

Syntax

Weekday(date[,firstdayofweek])  

Parameter Description

  • Date, a Required Parameter. The Week day would be returns for this specified date.

  • 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: " & Weekday("2013-05-16",1) & "<br />")
         document.write("Line 2: " & Weekday("2013-05-16",2) & "<br />")
         document.write("Line 3: " & Weekday("2013-05-16",2) & "<br />")
         document.write("Line 4: " & Weekday("2010-02-16") & "<br />")
         document.write("Line 5: " & Weekday("2010-02-17") & "<br />")
         document.write("Line 6: " & Weekday("2010-02-18") & "<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: 5
Line 2: 4
Line 3: 4
Line 4: 3
Line 5: 4
Line 6: 5
vbscript_date.htm
Advertisements