HiI have the following script and it works fine with two dates and half days however I need to add more script to deduct public holidays, could be multiple within the dates chosen, between Christmas/New Year there are usually 4-5 public holidays. Any advice would be greatly appreiciated.
Coll
See Code below:
Sub Postrecalc(Source As Notesuidocument)
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIdocument
Set uidoc=ws.currentDocument
Dim doc As NotesDocument
Set doc = source.Document
Const Saturday = 7
Const Sunday = 1
’ must have valid dates…
If doc.StartDate(0)="" Or doc.EndDate(0)="" Then
Exit Sub
End If
Dim count As Integer
count = 0 ' half days
Dim dtVacationDayStart As New NotesDateTime(doc.startdate(0) )
Dim dtVacationDayEnd As New NotesDateTime(doc.enddate(0) )
'Determine if the user has requested an end date before the start date
If dtVacationDayStart.TimeDifference(dtVacationDayEnd ) > 0 Then
Messagebox "you can't do that"
Exit Sub
Else
Dim strVacationDate As String
strVacationDate=dtVacationDayStart.DateOnly
Dim dtVacationDay As New NotesDateTime(strVacationDate )
Dim vacationdays As Integer
Dim itemHolidays As NotesItem
Set itemHolidays=doc.GetFirstItem("Holidays")
Dim w As Integer
While Not (dtVacationDay.dateOnly >dtVacationDayEnd.DateOnly)
If Not (Weekday(dtVacationDay.DateOnly)=Saturday Or Weekday(dtVacationDay.DateOnly)=Sunday) Then
If Not(ItemHolidays.Contains(dtVacationDay)) Then
count=count+2
End If
End If
Call dtVacationDay.AdjustDay(1)
Wend
’ adjust for half days…
If doc.HalfDay(0) <> "" Then count = count - 1
If doc.EndHalf(0) <> "" Then count = count - 1
doc.TotalDays2 = count / 2 ' display result
End If
'Call uidoc.Refresh
End Sub