
- VBScript Tutorial
- VBScript - Home
- VBScript - Overview
- VBScript - Syntax
- VBScript - Enabling
- VBScript - Placement
- VBScript - Variables
- VBScript - Constants
- VBScript - Operators
- VBScript - Decisions
- VBScript - Loops
- VBScript - Events
- VBScript - Cookies
- VBScript - Numbers
- VBScript - Strings
- VBScript - Arrays
- VBScript - Date
- VBScript Advanced
- VBScript - Procedures
- VBScript - Dialog Boxes
- VBScript - Object Oriented
- VBScript - Reg Expressions
- VBScript - Error Handling
- VBScript - Misc Statements
- VBScript Useful Resources
- VBScript - Questions and Answers
- VBScript - Quick Guide
- VBScript - Useful Resources
- VBScript - Discussion
VBScript WeekDay Function
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