Question : DateAdd for business days

I need some help with the below code to return only business days (M-F) in a form.  The below only returns calendar days.  In this example, I'm trying to add 2 business days to the field [Request D/T] and enter the results in the field [Determination Compliance Deadline D/T].

If [State or Federal Mandates_ID] = 4 And [Review Level_ID] = 2 Then
    [Determination Compliance Deadline D/T] = DateAdd("w", 2, [Request D/T])
End If

Any ideas?

Thank you!

Answer : DateAdd for business days

you will need a function to do that

place this codes in  a module

Function getDeadLineDate(dDate As Date, Span As Integer) As Date
Dim j As Integer, i As Integer, dtStart
dtStart = dDate
For j = 1 To Span
    dtStart = dtStart + 1
    Do While Weekday(dtStart) = 1 Or Weekday(dtStart) = 7 '_
        dtStart = dtStart + 1
        i = i + 1
    Loop
Next
getDeadLineDate = DateAdd("d", i + Span, dDate)

End Function




to use

If [State or Federal Mandates_ID] = 4 And [Review Level_ID] = 2 Then
    [Determination Compliance Deadline D/T] = getDeadLineDate([Request D/T],2)
End If

Random Solutions  
 
programming4us programming4us