Function Dates Times Class

LastDayOfWeekInMonth

Returns the last day of the week (for example, the last Tuesday) in the specified month.

Signature (Visual Basic / VBA)

Public Function LastDayOfWeekInMonth( _
      ByVal vYear As Variant _
    , ByVal vMonth As Variant _
    , ByVal vDayOfWeek As Variant _
    ) As Variant

Code Example

    Weekday(#1/31/96#) = vbWednesday
    LastDayOfWeekInMonth(1996, 1, vbWednesday) = #1/31/96#
    LastDayOfWeekInMonth(1996, 1, vbMonday) = #1/29/96#
    LastDayOfWeekInMonth(1996, 1, vbThursday) = #1/25/96#

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.
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

v2.0 Addition This function is new to this version of Entisoft Tools.