Hey all,
I have developed a solution for adding or subtracting business days. I posted the code below and with a simple if statement you should also be able to weed out holidays as well. Enjoy
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Dim num As Integer
Dim totaldays As Integer
Dim newtotal As Integer
Dim dateTime As NotesDateTime
Dim temp As String
Dim dateTime2 As Variant
Dim dateTime3 As NotesDateTime
Dim dateTime4 As Variant
Dim x As Variant, wd As Integer
Dim counter1 As Integer
Dim counter2 As Integer
' Calculates Business days based on a start date and a given number of business days.
' To move a date back you must enter a negative number in the field (days)
Set dateTime = New NotesDateTime(Cdat(uidoc.FieldGetText("date")))
dateTime2 = dateTime.DateOnly
Call uidoc.FieldSetText("date2",datetime2)
Do Until counter1 = Cint(uidoc.FieldGetText("days"))
wd = Weekday(dateTime.DateOnly)
If wd > 0 Then
If Cint(uidoc.FieldGetText("days")) > 0 Then
counter2 = counter2 + 1
Else
counter2 = counter2 - 1
End If
’ counter2 = counter2 + 1
If wd = 2 Or wd = 3 Or wd =4 Or wd =5 Or wd = 6 Then
If Cint(uidoc.FieldGetText("days")) > 0 Then
counter1 = counter1 + 1
Else
counter1 = counter1 - 1
End If
End If
End If
If Cint(uidoc.FieldGetText("days")) > 0 Then
Call dateTime.AdjustDay(1)
Else
Call dateTime.AdjustDay(-1)
End If
Loop
Set dateTime3 = New NotesDateTime(Cdat(uidoc.FieldGetText("date2")))
Call dateTime3.AdjustDay(counter2)
wd = Weekday(dateTime3.DateOnly)
If wd = 7 Then
If Cint(uidoc.FieldGetText("days")) > 0 Then
Call dateTime3.AdjustDay(2)
Else
Call dateTime3.AdjustDay(-1)
End If
Elseif wd = 1 Then
If Cint(uidoc.FieldGetText("days")) > 0 Then
Call dateTime3.AdjustDay(1)
Else
Call dateTime3.AdjustDay(-2)
End If
Else
'do nothing
End If
dateTime4 = dateTime3.DateOnly
Call uidoc.FieldSetText("newdate",datetime4)
End Sub