

VBA基础
Access函数判断每月最后一个周五是几号
2017-03-02 17:15:41
自定义函数判断每个月最后一个周五的日期
Public Function GD(mDate As Date, W As Integer) As Date
Dim LastDateOfMonth As Date
Dim i As Integer
LastDateOfMonth = DateAdd("m", 1, DateSerial(Year(mDate), Month(mDate), 1)) - 1
For i = 0 To 6
If Weekday(LastDateOfMonth - i, vbMonday) = W Then
GD = LastDateOfMonth - i
Exit For
End If
Next
End Function