• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 531
  • Last Modified:

Total Workdays Calculation

What is the easiest way to calculate total number of workdays between two dates in Access 97?
0
mgt4rwg
Asked:
mgt4rwg
  • 2
1 Solution
 
nathanielIT ConsultantCommented:
Try this function:

Function NoOfWorkingDays(BeginDate As Date, EndDate As Date)
Dim ctr As Date, NDay As Integer, WDay As Integer
WDay = 0
For ctr = BeginDate To EndDate
    NDay = WeekDay(ctr)
    WDay = WDay + 1
    If NDay = 1 Or NDay = 7 Then WDay = WDay - 1
Next ctr
NoOfWorkingDays = WDay
End Function

Value returned returned:
1 = Sunday; 2 = Monday; 3 = Tuesday;....; 7 = Saturday


Example:

from debug window;  

? NoOfWorkingDays(#9/1/98#,#9/10/98#)




0
 
nathanielIT ConsultantCommented:
The value will return no. of working days between two dates.

0
 
mgt4rwgAuthor Commented:
This was actually for a friend of mine.  He says the code appears to be functioning correctly and returning valid dates!  Thanks for your help. I only wish Microsoft would document this function in its documentations.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now