WEEKDAY(date, [firstdayofweek])

Returns the number representing the day of the week for a given date (Integer).


dateThe date you want the day for (Date).
firstdayofweek(Optional) A vbDayOfWeek constant that specifies the first day of the week (Integer):
0 = vbUseSystem
1 = vbSunday (default)
2 = vbMonday
3 = vbTuesday
4 = vbWednesday
5 = vbThursday
6 = vbFriday
7 = vbSaturday

REMARKS
* If "firstdayofweek" is left blank, then 1 (vbSunday) is used.
* If the Calendar property setting is Gregorian, the returned integer represents the Gregorian day of the week for the date argument. If the calendar is Hijri, the returned integer represents the Hijri day of the week for the date argument. For Hijri dates, the argument number is any numeric expression that can represent a date and/or time from 1/1/100 (Gregorian Aug 2, 718) through 4/3/9666 (Gregorian Dec 31, 9999).
* This function was added in Office 2000.
* The equivalent Excel function is Application.WorksheetFunction.WEEKDAY
* The equivalent .NET function is Microsoft.VisualBasic.DateAndTime.Weekday
* For the Microsoft documentation refer to docs.microsoft.com

Debug.Print Format("06/07/2009","dddd") '= Monday  
Debug.Print Weekday(#06/07/2009#, vbMonday) '= 7
Debug.Print Weekday(#07/07/2009#, vbMonday) '= 1
Debug.Print Weekday(#08/07/2009#, vbMonday) '= 2
Debug.Print Weekday(#12/07/2009#, vbMonday) '= 6
Debug.Print Weekday(#06/07/2009#, vbSunday) '= 1
Debug.Print Weekday(#06/07/2009#, vbSunday) '= 7
Debug.Print Weekday(#06/07/2009#, vbMonday) '= vbDayOfWeek.vbSaturday
Debug.Print Weekday(#06/07/2009#, vbMonday) '= vbDayOfWeek.vbMonday
Debug.Print Now() = ??
Debug.Print Weekday(Date) '= 6
Debug.Print Weekday(Date, vbMonday) '= 5
Debug.Print Weekday(Date, vbUseSystemDayOfWeek) '= 5
If Weekday(Now, vbMonday) '= 1 Then 'it is a Monday
If Weekday(Now, vbMonday) '= 2 Then 'it is a Tuesday
If Weekday(Now, vbMonday) '= 3 Then 'it is a Wednesday
If Weekday(Now, vbWednesday) '= 1 Then 'it is a Wednesday

© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited Top