Solved

Script Help

Posted on 2002-05-20
4
185 Views
Last Modified: 2013-12-18
Our company is going to a 24/7 work week.  On our vacation database, when calculating days, excludes weekends. How can I change the below code to count weekends as business days?

Code:
Sub CalculateDays
     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
     'Few new dims
     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("EDChange", 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 95 total points
ID: 7021857
Change this line

"If days <> 1 And days <> 7 Then"

to "If True then"

or remove it

~Hemanth
0
 

Author Comment

by:schmad01
ID: 7022110
Awesome.  Thanks. Heman.  One of these days I will learn script.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7022178
Sure, And EE is the best place to learn.
0
 

Author Comment

by:schmad01
ID: 7022183
You got that right!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
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.

760 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

17 Experts available now in Live!

Get 1:1 Help Now