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

Total Workdays Calculation

What is the easiest way to calculate total number of workdays between two dates in Access 97?
  • 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


from debug window;  

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

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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