- Function GetNthWeek(sDate)
- Dim dt, daysElapsed, wd, n
- dt = CDate(sDate)
- daysElapsed = DateDiff("d", Year(dt) & "-1-1", dt)
- wd = Weekday(CDate(Year(dt) & "-1-1"), 2)
- If wd = 1 Then
- n = daysElapsed \ 7
- If (daysElapsed Mod 7) <> 0 Then n = n + 1
- Else
- If daysElapsed < (7 - wd + 1) Then
- n = 1
- Else
- daysElapsed = daysElapsed - (7 - wd + 1) + 1
- n = (daysElapsed \ 7) + 1
- If (daysElapsed Mod 7) <> 0 Then n = n + 1
- End If
- End If
- GetNthWeek = n ‘返回函数值,重要
- End Function
复制代码
|