|
请高手帮忙,现在有2个表,一个是HolidayDate,一个是AdditionalWorkingDay,分别代表节假日和原为休息日但由于节假日更改为工作日的日期,麻烦看一下这个dateadd 函数是否有问题,多谢。主要是有节假日就跳过,额外工作日则要加上。
Public Function DraftBFLDueDate(startdate As Variant, D As Variant) As Date
'On Error GoTo Err_DraftBFLDueDate
Dim intCount As Integer
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim rstAWD As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT [HolidayDate] FROM Holidays", dbOpenSnapshot)
Set rstAWD = db.OpenRecordset("SELECT [AdditionalWorkingDay] FROM AdditionalWorkingDay", dbOpenSnapshot)
intCount = 0
Do While intCount < D
rst.FindFirst "[HolidayDate] = #" & startdate & "#"
rstAWD.FindFirst "[AdditionalWorkingDay] = #" & startdate & "#"
If Weekday(startdate) <> vbSunday And Weekday(startdate) <> vbSaturday Or rstAWD.NoMatch = "false" Then
If rst.NoMatch Then intCount = intCount + 1
End If
startdate = startdate + 1
Loop
DraftBFLDueDate = startdate - 1
rst.Close
rstAWD.Close
'Exit_DraftBFLDueDate:
'Exit Function
'Err_DraftBFLDueDate:
'Select Case Err
'Case Else
'MsgBox Err.Description
'Resume Exit_DraftBFLDueDate
'End Select
End Function |
|