Solved

More Script Help

Posted on 2002-06-14
4
175 Views
Last Modified: 2013-12-18
How can I modify the below code to include weekends as business days.  We are moving to a 24/7 operation:

Sub CalculateBusinessDays
     Dim session As New NotesSession    
     Dim workspace As New NotesUIWorkspace
     Dim doc As NotesDocument
     Dim uidoc As NotesUIDocument
     Dim startdate As NotesDateTime
     Dim enddate As NotesDateTime
     Dim startitem As NotesItem
     Dim enditem As NotesItem
     Dim counter As Integer
     Dim flag As Integer
     Dim days As Integer
     Dim hookdoc As NotesDocument
     Dim hookview As NotesView
     Dim db As NotesDatabase
     Dim duration() As String
     
     Set db = session.CurrentDatabase
     Set uidoc = workspace.CurrentDocument
     Set doc = uidoc.Document
     If workspace.DialogBox("BDChange", True, True, False, False, False, False, "Please Select the Beginning and Ending Dates.") Then
          doc.Counter = 2
         
          'if either field is empty don't do calculations and blank out days field.
          If doc.StartDate(0) = "" Or doc.EndDate(0) = "" Then
               doc.TotalDays = ""
               End
          End If
          Set startitem = doc.GetFirstItem("StartDate")
          Set startdate = startitem.DateTimeValue
          Set enditem = doc.GetFirstItem("EndDate")
          Set enddate = enditem.DateTimeValue
          counter = 0
         
          'Make sure that the start date is before the end date
          If startdate.TimeDifference(enddate) > 0 Then
               Messagebox "The Start Date cannot come after the End Date.", 16, "Incorrect Dates"
               Call uidoc.GoToField("StartDate")
               End
          End If
         
          'Get the list of Holidays
          Set hookview = db.GetView("Holidays")
          Set hookdoc = hookview.GetDocumentByKey("Holidays",True)
         
         
          Do While startdate.TimeDifference(enddate) <= 0   'Once we check the end date we're done!!
               flag = 0
               days = Weekday(startdate.LSLocalTime)
               If days <> 1 And days <> 7 Then
                    'check for holidays
                    Forall holiday In hookdoc.AllHolidays
                         If Cdat(holiday) = startdate.LSLocalTime Then flag=1
                    End Forall
                   
                    If flag =0 Then
                         Redim Preserve duration(0 To counter)
                         duration(counter) = startdate.LSLocalTime
                         counter = counter +1
                    End If
               End If
               Call startdate.AdjustDay(1)
          Loop
          doc.TotalDays = counter
          doc.Duration = duration
          Call uidoc.Refresh
     End If
End Sub
0
Comment
Question by:schmad01
  • 2
  • 2
4 Comments
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 70 total points
ID: 7078217
In your code

If days <> 1 And days <> 7 Then


is the only statement which prevents to count sat and sun days. Remove that if and you should be all set.

~Hemanth
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7078232
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7078393
No wonder I had this feeling that I answered similar kind of question :-)
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7082113
:-)

Then you both are on good track :-)

Why not play it one more time? Hello Alzheimer :-)

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now