Function Day2weeky(Optional dates = "") '每月第几周,包含4日的为第一周
If dates = "" Then dates = Date
nf = Year(dates)
yf = month(dates)
yy = Day(DateSerial(nf, yf, 0)) - 3
If dates > DateSerial(nf, yf, yy) And Weekday(DateSerial(nf, yf + 1, 1), 2) < 5 Then
Day2weeky = Format((yf Mod 12) + 1, "00") & "01": Exit Function
End If
qsrq = Weekday(DateSerial(nf, yf, 4), 2)
qsr = DateSerial(nf, yf - 1, yy) + 7 - qsrq
Day2week1 = -Int(-(dates - qsr) / 7)
Day2weeky = Format(yf, "00") & Format(Day2week1, "00")
End Function
|