View Poll Results: HOW IS THE BEST WAY TO DO THIS?

Voters
1. You may not vote on this poll
  • CREATING A TABLE OF BANKING HOLIDAYS

    0 0%
  • OTHER WAYS

    1 100.00%
Results 1 to 2 of 2
  1. #1
    JOSE LUIS is offline Novice
    Windows 7 Access 2007
    Join Date
    Jan 2010
    Location
    LEON-SPAIN
    Posts
    3

    Wink calculate no. of working days

    First of all I´m sorry for my English. I´m an a rockie in access and I´m like to question the forum about how I can create a date function than calculate the amount of working days between dates (startdate and endate) after take into account the banking holidays that are previously introduced in a table. I don´t Know if this is the best way to do it.
    > Best regards


    > JOSE LUIS

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Here's what I use and YES I create a holiday table.
    Code:
    Public Function WorkingDays(StartDate As Date, EndDate As Date) As Integer
    '-- Return the number of WorkingDays between StartDate and EndDate
        On Error GoTo err_workingDays
        Dim intCount As Integer
        If IsDate(StartDate) And IsDate(EndDate) Then
            If EndDate >= StartDate Then
                intCount = 0
                Do While StartDate < EndDate
                    StartDate = StartDate + 1
                    If Weekday(StartDate, vbMonday) <= 5 Then
                        '-- Use the following code if you have a "Holiday" table
                        '         If Weekday(StartDate, vbMonday) <= 5 And _
                                  IsNull(DLookup("[Holiday]", "tblHolidays", _
                                  "[HolDate] = " & Format(StartDate, "\#mm\/dd\/yyyy\#;;;\N\u\l\l"))) Then
                        intCount = intCount + 1
                    End If
                Loop
                WorkingDays = intCount
            Else
                WorkingDays = -1    '-- To show an error
            End If
        Else
            WorkingDays = -1    '-- To show an error
        End If
    exit_workingDays:
        Exit Function
    err_workingDays:
        MsgBox "Error No:    " & Err.Number & vbCr & _
               "Description: " & Err.Description
        Resume exit_workingDays
    End Function

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Print next 8 days & info
    By skippernick in forum Reports
    Replies: 2
    Last Post: 04-06-2010, 12:38 PM
  2. Travel days.
    By emccalment in forum Access
    Replies: 1
    Last Post: 01-06-2010, 05:39 PM
  3. less than 180 days old
    By techexpressinc in forum Queries
    Replies: 2
    Last Post: 06-04-2009, 04:29 PM
  4. Default Value in table = Field plus 3 days
    By AmyLynnHill in forum Access
    Replies: 1
    Last Post: 08-03-2008, 01:58 AM
  5. Total no of days in a month
    By wasim_sono in forum Forms
    Replies: 4
    Last Post: 10-15-2006, 01:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums