INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Microsoft: Access Forms FAQ

## How to

 Find the working days between Dates by Rolliee faq702-4851 Posted: 16 Feb 04 The following code in a global module will find the number of working days between two dates. Only Mondays thry Fridays are counted. If there is a table named "Holidays" the function opens it once and makes a public array of holidays. The first field must hold the dates.  If no table is provided, only Christmas, The Fourth, New Years and MY Birthday are listed The form is me.txtNumDays = GetDay( me.date1, me.date2)Rollie EPublic HDi(12) As Date, iHDi As IntegerPublic Function GetDay(ByVal d1 As Date, ByVal d2 As Date) As LongDim rs As DAO.Recordset, Numof As Long, i As IntegerNumof = 0  Do While d2 > d1     If good1(d2) Then Numof = Numof + 1     d2 = d2 - 1  LoopGetDay = NumofIf iHDi = 0 Then    On Error GoTo tellme:    Set rs = CurrentDb.OpenRecordset("holidays")    rs.MoveLast: rs.MoveFirst    Do While Not rs.EOF      HDi(i) = rs.Fields(0)      iHDi = iHDi + 1      rs.MoveNext    Loop    GoTo around:tellme:     If Err.Number = 3078 Then         HDi(0) = CDate("12/25/2004")         HDi(1) = CDate("7/4/2004")         HDi(2) = CDate("1/1/2005")         HDi(3) = CDATE("9/1/2004")         iHDi = 4         Exit Function     End Ifaround:     rs.Close     Set rs = Nothing End IfEnd FunctionPublic Function good1(d2 As Date) As BooleanDim okay As Boolean, i As Integerokay = FalseSelect Case Weekday(d2)  Case 2, 3, 4, 5, 6    okay = True   Case 1, 7    okay = FalseEnd Selectgood1 = okayIf okay Then     For i = 0 To iHDi - 1       If HDi(i) = d2 Then okay = False     NextEnd IfEnd Function Back to Microsoft: Access Forms FAQ Index Back to Microsoft: Access Forms Forum

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!