LastDateOfDayInMonth

Syntax:

LastDateOfDayInMonth(dateexpr, NumZ{day})

Description: 

Returns the date of the last instance of the specified day in the month of the date specified. For example, this function could return the date of the last Monday of next month.

Parameters:

Parameter

Description

dateexpr

The date to be used when determining the last instance of the day in the month.

NumZ{day}

The day to check for.

 

The return integer is one of the following:

NumZ{day}

Value

Description

vbSunday

1

Sunday

vbMonday

2  

Monday

vbTuesday

3

Tuesday

vbWednesday

4

Wednesday

vbThursday

5

Thursday

vbFriday

6

Friday

vbSaturday

7

Saturday

 

Example


Sub Main
'return the date of the last Sunday of this month.
  lastSundayofthismonth= LastDateOfDayInMonth(Now(),1)

'return the date of the last Friday of next month.
  lastMondayofnextmonth = LastDateOfDayInMonth(DateAdd(1,"m",Now()),6)
End
Sub


See Also:

IsLeapYear, FirstDateOfDayInMonth, FirstDateOfDayInQuarter, FirstDateOfDayInYear, LastDateOfDayInQuarter, LastDateOfDayInYear, LastDateOfWeek, LastDayOfMonth, LastDayOfQuarter, LastDayOfYear