作者: tomzy 时间: 2003-6-2 17:50
提示: 作者被禁止或删除 内容自动屏蔽作者: 逸致1 时间: 2003-6-8 09:36
谢谢指教。作者: Trynew 时间: 2003-6-8 21:00
大于一周的天数每周5天不用判断,下面是一个取得工作日的函数(不判断节假日):
Public Function WorkDays(BeginDate As Date, EndDate As Date) As Integer
Dim i As Integer
If EndDate < BeginDate Then Exit Function
WorkDays = (((EndDate - BeginDate) + 1) \ 7) * 5
For i = 0 To ((EndDate - BeginDate) + 1) Mod 7 - 1
'判断是否为星期六或星期天
If Weekday(EndDate - i, vbSaturday) <> 1 And _
Weekday(EndDate - i, vbSaturday) <> 2 Then
WorkDays = WorkDays + 1
End If
Next
End Function