@BusinessDays In LS
June 16, 2007 – 10:25 amIn R6 you can use @BusinessDays to calculate the number of working days between one date and another, excluding non-working days and a list of dates to exclude as well. As there is no equivalent in LotusScript, I wrote a small class to simulate @BusinessDays in LS.
Actually I did not reinvent the wheel, but simply used evaluate in combination with @BusinessDays to achieve the aim.
Here is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | Class BusinessDay Private holidays As String Private nondays As String Sub New (strExcludeDays As String,strExcludeDates As String) holidays = "[01/01/1899]" nondays = "0" If strExcludeDays <> "" Then nondays = strExcludeDays End If If strExcludeDates <> "" Then holidays = strExcludeDates End If End Sub Public Function GetBusinessDays(dtStart As String,dtEnd As String) As Integer Dim bd As Variant Dim StartDT As New NotesDateTime(dtStart) Dim EndDT As New NotesDateTime(dtEnd) GetBusinessDays = 0 bd = Evaluate({@BusinessDays([}&_ Cdat(StartDT.DateOnly)& {];[}&_ Cdat(EndDT.DateOnly)& {];}&_ Me.nondays &{;}&_ Me.holidays &_ {)}) GetBusinessDays = Cint(bd(0)) End Function End Class |
To test the code, put the code into the declaration section of a button. In your “Click” event type
1 2 3 4 5 6 7 8 9 10 11 | Sub Click(Source As Button) Dim dtStart As String Dim dtEnd As String dtStart = "05.06.2007" dtEnd = "11.06.2007" 'Dim b As New BusinessDay("1:7","[08.06.2007]:[06.06.2007]:[07.06.2007]") 'Dim b As New BusinessDay("","[08.06.2007]:[06.06.2007]:[07.06.2007]") Dim b As New BusinessDay("","") Msgbox b.GetBusinessDays (dtStart,dtEnd ) End Sub |





Sorry, comments for this entry are closed at this time.