Manage Learn to apply best practices and optimize your operations.

Calculate The Number Of Weekdays Between Two Date Fields (Excluding Weekends And Holidays) Through

A Simple & generic script to find out the difference between two date,
excluding Sunday & Saturday and any other Public Holiday... Can be widely used
thoroughtout the Database...

1.Create and View and input all the dates of the year on which the leave is
given (holiday in this code)
2. create a script Library in order to use this whereever required.
The Code on the trigger
Dim Date1 As notesdatetime
Dim Date2 As notesdatetime
Set Date1 = New notesdatetime(doc.FirstDate(0))
Set Date2 =New notesdatetime(doc.SecondDate(0))
Differ# = Date2.TimeDifference(Date1)
If Differ# > 0 Then
Days% = Differ# / 86400
Days% = CycleTimeDate1,Date2,days%)
doc.CT1 = Days% 'where CT1 is a Field to capture the difference and
store it in a form
doc.CT1 = 0
End If

In a Library create a function "Cycletime"

Function CycleTime(Date1 As notesdatetime, Date2 As notesdatetime,days As
Dim hdoc As notesdocument
Dim view As notesview
Dim Y As Integer,x As Integer

Set ses = New notessession
Set Cdb = ses.currentdatabase
Set view = Cdb.getview("holiday")
x% = days%
Y% = 0
Do Until Y% = x%
Y% = Y%+ 1
Call Date1.AdjustDay(1)
Wday1$ = Cstr(Date1.LocalTime)
Set hdoc = view.getdocumentbykey(Wday1$ )
If Not hdoc Is Nothing Or Weekday(Date1.DateOnly)=1 Or
Weekday(Date1.DateOnly)= 7 Then
days% = days% - 1
CycleTime = days%
CycleTime = days%
End If
End Function

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...