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

# Total Workdays Calculation

What is the easiest way to calculate total number of workdays between two dates in Access 97?
0
mgt4rwg
• 2
1 Solution

IT 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

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

0

Author 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.