David
asked on
DateAdd for business days or calendar days which ever is greater
capricorn1 was able to help with the below answer. I have another question that is a bit more complex. My original question was how to create a module and expression to calculate business days.
The answer is:
"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"
I have another question... I want to use a similar expression to decide to use "which ever is greater" when it comes to business days or calendar days. I need a formula that calculates either 1 business day or 72 hours which ever is greater. This seems to only be a problem on Fridays. I need it to use 1 business day if it is Friday otherwise use 72 hours.
Thanks for the help!
The answer is:
"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"
I have another question... I want to use a similar expression to decide to use "which ever is greater" when it comes to business days or calendar days. I need a formula that calculates either 1 business day or 72 hours which ever is greater. This seems to only be a problem on Fridays. I need it to use 1 business day if it is Friday otherwise use 72 hours.
Thanks for the help!
define how 1 business day can be greater then 72 hours and vice versa.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you!
You are welcome!
/gustav
/gustav