Voor een applicatie moest herhaaldelijk uitgerekend worden hoeveel dagen er in een bepaalde periode zitten.
De volgende functie voldeed hier goed:
Input: getDaysBetween(“31-12-2007″,”01-01-2007”, “1,7” ,”25/12/07 – 26/12/07,05-12-2007″,Doc)
Output: 258
Function getDaysBetween(strStart As String, strEnd As String,daysToExclude As String , datesToExclude As String ,Doc As NotesDocument) As Long
On Error GoTo ErrorHandler
Dim Formula As Variant
Dim dLow As String
Dim dHigh As String
If strStart = “” Or strEnd = “” Then GoTo ErrorHandler
strStart = {@TextToTime(“} & strStart & {“)}
strEnd= {@TextToTime(“} & strEnd & {“)}
If daysToExclude = “” Then
dLow = {;0}
Else
dLow = {;@TextToNumber(@Explode(“} & daysToExclude & {“;”,”))}
End If
If Not datesToExclude = “” Then
dLow = dLow & {;@TextToTime(@Explode(@TextToTime(@Explode(“} & datesToExclude & {“;”,”))))}
End If
dHigh$ = {@BusinessDays(} & strStart$ & {;} & strEnd$ & dLow & {)}
dLow$ = {-@BusinessDays(} & strEnd$ & {;} & strStart$ & dLow & {)}
Formula = Evaluate({@If(} & strStart & {>} & strEnd & {;} & dLow$ & {;} & dHigh$ & {)} ,Doc)
getDaysBetween = CLng(Formula(0))
Exit Function
ErrorHandler:
MsgBox GetThreadInfo(1) & ” ” & Error & ” (” & Err & “) op regel ” & Erl & “.”
getDaysBetween = 0
Exit Function
Resume Next
End Function