Solved

Total Workdays Calculation

Posted on 1998-09-29
3
485 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

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…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

839 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