Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: RE: Excluding Weekends and Holidays


Message #1 by "Leah" <leah@k...> on Tue, 10 Jul 2001 17:27:14 -0400
Here's how I do it for weekends. Also, I have a table of holidays. I have

another function that retrieves the list of holidays for a given time

period. For each holiday, subtract one from minStandardDays. If there are no

records returned, there is nothing to subtract.



If you are dealing in whole days, there shouldn't be a problem. You may have

to do some more data manipulation if you're reporting in smaller intervals.



Hope this helps. Feel free to ask for clarification.

Leah



In one module:



	  lngNumberOfDays = DateDiff("d", dtFirstDate, pdtTSDate)

        mintStandardDays = 0



        For lngCounter = 0 To lngNumberOfDays - 1



        dtTempDate = DateAdd("d", lngCounter, dtFirstDate)

        If GetDayOfWeek(dtTempDate) <> "Sunday" And GetDayOfWeek(dtTempDate)

<> "Saturday" Then

            mintStandardDays = mintStandardDays + 1

        End If



'--Code from some public code site - forget which.

Public Function GetDayOfWeek(pdtDate) As String

Dim strDay As String

    Dim v As Integer

    v = Weekday(pdtDate)

    If v > 0 And v < 8 Then

        Select Case Weekday(pdtDate)

            Case 1

            strDay = "Sunday"

            Case 2

            strDay = "Monday"

            Case 3

            strDay = "Tuesday"

            Case 4

            strDay = "Wednesday"

            Case 5

            strDay = "Thursday"

            Case 6

            strDay = "Friday"

            Case 7

            strDay = "Saturday"

            Case Else

            strDay = "Unknown"

        End Select

End If

GetDayOfWeek = strDay

end function



-----Original Message-----

From: brose@u... [mailto:brose@u...]

Sent: Tuesday, July 10, 2001 9:28 PM

To: Access

Subject: [access] Excluding Weekends and Holiays





I am running a query that finds the time a ticket in oracle was open.

However, I need to take that total time and subtract the time of any

weekend days or holidays that may have been between the open and close

times of the record.



Is there any easy way to get the weekend days and holidays between two

dates? I noticed a function in the help file of Access called NETWORKDAYS

but when I try to use it Access doesn't recognize it as being a built in

function. Can this function be installed? Is there a better way or

alternative to it? Thanks for the help.








  Return to Index