• Browse Blogs
  • My Blog
  • My Updates

+Tags Get help with tags?

  • View as cloud  | list

+ Similar Entries

photo

Bringing The Power O...

Blog:  Beyond The Ye...
Peter Presnell
Updated 
No RatingsRatings 0     No CommentsComments 0
photo

Adding the "X" Facto...

Blog:  Beyond The Ye...
Peter Presnell
Updated 
No RatingsRatings 0     CommentsComments 2
photo

Tagging Design Eleme...

Blog:  Beyond The Ye...
Peter Presnell
Updated 
No RatingsRatings 0     CommentsComments 1
photo

Add Discussion Threa...

Blog:  Beyond The Ye...
Peter Presnell
Updated 
No RatingsRatings 0     CommentsComments 2
photo

New Video Includes S...

Blog:  Beyond The Ye...
Peter Presnell
Updated 
No RatingsRatings 0     No CommentsComments 0

+ Bookmarks

+ Blog Authors  

@BusinessDay

Peter Presnell |   | Tags:  .dominoframework | Comments (0)  |  Visits (389)

A common feature request I get for applications is the ability to adjust dates so that they do not fall on a weekend or a business holiday.  Whilst there is no @BusinessDay function, I often wish there is one.  The .Domino Framework now provides a LotusScript equivalence for what I envisage an @BusinessDay function should/could look like.  It takes a date or array of dates (of LS type DATE or NOTESDATETIME), and array of non-worrking  days and adjusts the dates so that none of them fall on a weekend or holiday.  This is available in the Domino.AFunctions namespace.

 

The code is as follows:-

 

/**
' * Returns a list of business days for a list of dates, adjusting those dates that fall on a weekend or holiday
' *
' * @author Peter Presnell
' * @param  Source     A list of one or more dates
' * @param Holidays    A list of dates that are considered non-working dates
' * @param MoveAfter    True = move date to next working day, False = move date to previous working day
' * @return  A list containing the dates adjusted for weekends and holidays
' */
Function atfBusinessDay(Source As Variant, Holidays As Variant,MoveAfter As Boolean) As Variant
 
 Dim Index   As Integer  ' Counter used to loop through arrays
 Dim Results  As Variant  ' Interim results of atfBusinessdays
 Dim DateTime As Variant  
Try: 
 On Error Goto Catch
atfBusinessDay = Source
 
' If array of dates passed then caluclate business days for each pair of dates
 
 If Isarray(Source) Then
  For Index% = Lbound(Source) To Ubound(Source) 
   Redim Preserve Result(Index%)
   Result(Index%) = atfBusinessDay(Source(Index%),Holidays,MoveAfter)
  Next Index%
  atfBusinessDay = Results
 Else
  Select Case Typename(Source)
  Case "DATE"
   While Weekday(Source) = 1 Or Weekday(Source) = 7 Or atfIsMember(Source,Holidays)
    If MoveAfter Then Source = Source + 1 Else Source = Source - 1
   Wend
   atfBusinessday = Source 
  Case "NOTESDATETIME"
   DateTime = Cdat(Source.DateOnly)
   While Weekday(DateTime) = 1 Or Weekday(DateTime) = 7 Or atfIsMember(DateTime,Holidays)
    If MoveAfter Then DateTime = DateTime + 1 Else DateTime = DateTime - 1
   Wend
   Set atfBusinessDay = New NotesDateTime(DateTime)
  End Select
 End If 
 Exit Function
Catch:
 Stop
 Call ReportError
 Exit Function
 
End Function

No RatingsRatings 0

Comments (0)

There are no comments to display Add a Comment Add a Comment

Previous |  Main  | Next
Skip to main content link. Accesskey S
IBM Lotus Connections Help Tools About