|
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
Private 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: Print Lsi_info(2) & " : Error " & Error & " (" & Err & ") on line " & Erl & "." getDaysBetween = 0 Exit Function Resume Next End Function
|