Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Total Workdays Calculation

Posted on 1998-09-29
3
Medium Priority
?
526 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 200 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

916 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