Solved

Total Workdays Calculation

Posted on 1998-09-29
3
478 Views
Last Modified: 2012-06-21
What is the easiest way to calculate total number of workdays between two dates in Access 97?
0
Comment
Question by:mgt4rwg
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
nathaniel earned 50 total points
ID: 1963803
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
 
LVL 6

Expert Comment

by:nathaniel
ID: 1963804
The value will return no. of working days between two dates.

0
 

Author Comment

by:mgt4rwg
ID: 1963805
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

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question