在Excel中有workdate函数,在ACCESS中却没有,因此写了一个自定义函数,供参考。
说明:
1、如果节假日占用了休息日,要减少节假日,比如放假7天,其中占用了周日,实际假日为6天
2、开始日期一定要为工作日,不能为节假日或休息日。
Public Function Access_Workdate(startDate As Date, Days As Long, Holidays As Long) As Date
'从某一工作日的日期(含该工作日)开始,多少个工作日后,后一天的工作日日期
'startDate '开始日期
'Days 天数
'Holidays,区间内的节假日天数
Dim endDate As Date
Dim m As Date
Dim i As Long
i = 1
endDate = startDate + (Days + Holidays) * 3
For m = startDate To endDate
If Weekday(m) > 1 And Weekday(m) < 7 Then
i = i + 1
If i = Days + Holidays Then
Access_Workdate = m + 2
Select Case Weekday(Access_Workdate)
Case 6
Access_Workdate = Access_Workdate + 3
Case 7
Access_Workdate = Access_Workdate + 2
End Select
Exit Function
End If
End If
Next m
End Function