?
Solved

More Script Help

Posted on 2002-06-14
4
Medium Priority
?
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 280 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

752 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