Signature (Visual Basic / VBA)
Public Function NthDayOfWeekInMonth( _
ByVal vYear As Variant _
, ByVal vMonth As Variant _
, ByVal vOccurrence As Variant _
, ByVal vDayOfWeek As Variant _
) As Variant
Code Example
Weekday(#1/1/96#) = vbMonday
NthDayOfWeekInMonth(1996, 1, 1, vbMonday) = #1/1/96#
NthDayOfWeekInMonth(1996, 1, 3, vbMonday) = #1/15/96#
NthDayOfWeekInMonth(1996, 1, 5, vbMonday) = #1/29/96#
IsNull(NthDayOfWeekInMonth(1996, 1, 6, vbMonday)) = True
Parameters
| Parameter | Description |
|---|---|
| vYear | Must use the full four-digit year; cannot use 96, for example, to mean 1996. Function returns Null if vYear is Null or cannot be interpreted as an integer number. |
| vMonth | Month in the year vYear. Function returns Null if vMonth is Null or cannot be interpreted as an integer number. |
| vOccurrence | Nth occurrence of the day of the week within the month to be returned. For example, use 1 for the first occurrence of the day of the week within the month, 2 for the second occurrence of the day of the week within the month, etc. Function returns Null if vOccurrence is Null or cannot be interpreted as an integer number. |
| vDayOfWeek | One of the vbDayOfWeek constants like vbSunday, vbMonday, etc. Function returns Null if vDayOfWeek is Null or cannot be interpreted as an integer number. |
Notes & Version History
| Note | This function will return Null if there is no Nth occurrence of the weekday within the month. For example, the function will return Null when asked for the 6th Monday in a month. |
| v2.0 Addition | This function is new to this version of Entisoft Tools. |