Private Function GetWeekDayStr(SolarDate As Date, m As Byte, n As Byte, w As Byte) As String
'根据日期查询是当月的第几周的周几
Dim tempDate As Date, tempW As Integer
tempDate = DateSerial(Year(SolarDate), Month(SolarDate), 1)
tempW = Weekday(tempDate)
m = Format(SolarDate, "mm")
n = Format(SolarDate, "WW") - Format(tempDate, "WW") + 1
w = Weekday(SolarDate)
If tempW > w Then n = n - 1
End Function
Sub test()
Dim d As Date, m As Byte, n As Byte, w As Byte
d = #1/18/2009#
Call GetWeekDayStr(d, m, n, w)
Debug.Print d & "是" & m & "月的第" & n & "个" & WeekdayName(w)
End Sub
Access软件网交流QQ群(群号:198465573) |