473,785 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Average number of workdays per month from table

7 New Member
I figured out how to calculate the work day given two values but all of my records have dates and i want to be able to calcuate the average time it takes to do a job per month so basically take all the calculations add them up and divide by the total does anyone know how to do that.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Function WorkingDays2(StartDate As Date, EndDate As Date) As Integer
  3. '....................................................................
  4. ' Name: WorkingDays2
  5. ' Inputs: StartDate As Date
  6. ' EndDate As Date
  7. ' Returns: Integer
  8. ' Author: Arvin Meyer
  9. ' Date: May 5,2002
  10. ' Comment: Accepts two dates and returns the number of weekdays between them
  11. ' Note that this function has been modified to account for holidays. It requires a table
  12. ' named tblHolidays with a field named HolidayDate.
  13. '....................................................................
  14. On Error GoTo Err_WorkingDays2
  15. Dim intCount As Integer
  16. Dim rst As DAO.Recordset
  17. Dim DB As DAO.Database
  18.     Set DB = CurrentDb
  19.     Set rst = DB.OpenRecordset("SELECT [HolidayDate] FROM tblHolidays", dbOpenSnapshot)
  20.  
  21.     'StartDate = StartDate + 1
  22.     'To count StartDate as the 1st day comment out the line above
  23.     intCount = 0
  24.  
  25.     Do While StartDate <= EndDate
  26.         rst.FindFirst "[HolidayDate] = #" & StartDate & "#"
  27.         If Weekday(StartDate) <> vbSunday And Weekday(StartDate) <> vbSaturday Then
  28.         If rst.NoMatch Then
  29.             intCount = intCount + 1
  30.         End If
  31.         StartDate = StartDate + 1
  32.     Loop
  33.  
  34.     WorkingDays2 = intCount
  35. Exit_WorkingDays2:
  36.     Exit Function
  37. Err_WorkingDays2:
  38.     Select Case Err
  39.     Case Else
  40.         MsgBox Err.Description
  41.     Resume Exit_WorkingDays2
  42.     End Select
  43. End Function
  44.  
Jun 13 '07 #1
1 9187
NeoPa
32,578 Recognized Expert Moderator MVP
Perhaps you wouldn't mind rewriting the question with some punctuation.
Jul 4 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
5316
by: Stephen Miller | last post by:
Hi, I am trying to add a staggered running total and average to a query returning quarterly CPI data. I need to add 4 quarterly data points together to calculate a moving 12-month sum (YrCPI), and then to complicate things, calculate a moving average of the 12-month figure (AvgYrCPI). Given the sample data:
1
4914
by: Annette Massie | last post by:
I would like to have a crosstab of the number of campers by month as row headings and by year as column headings with an additional column of the average. So, in January we had 10 campers for 1999, 20 campers in 2000, 5 campers in 2001, 30 campers in 2002 and 50 campers in 2003. The row heading would be January (and then February, March, April, May, etc., with all of its data), the column headings would be 1999, 2000, 2001, 2002 and...
4
7182
by: david.monaghan | last post by:
I have a table with the following fields - Location, Manager, CostCentre, Month and Headcount. What I am trying to do is a monthly rolling average headcount by Location, Manager, CostCentre. To verify the calculations I am using sum rather then average and the query below is showing the sum of all records in the month rather then breaking it down by the Location, Manager, CostCentre combinations. SELECT test.Loc, test., test.CC,...
6
3138
by: J | last post by:
Kind of new at programming/vb.net. I'm doing this junky die roller program. Heres's what is supposed to happen: Roll 2 6-sided dies. Add rolls together put total in rolls(d6total). Display the number of 2 or 12 rolled, then display those numbers and average rolls. I didn't know how to do it exactly, but I came up with this.
3
2317
by: C++Geek | last post by:
I need to get this program to average the salaries. What am I doing wrong? //Program to read in employee data and calculate the average salaries of the emplyees.
3
4493
by: simpleeshelbee | last post by:
Hey guys, This is my second post and is URGENT!!!! My final assignment is due tonite for class and I have no idea how to write this program right! I am supposed to write a program that uses a two-dimensional array to store the highest and lowest temperatures (in farenheit) for each month of the year. The program is supposed to output the average high, average low and the highest and lowest temperatures of the year. I need it to print out as...
10
15992
by: Nightspeace | last post by:
Hello Everyone, I am currently trying to create a 3 month running wieghted average to forecast the comming months. My Table consits of 3 colums (Table ID), (Date),(Monthly Total). (Table ID) contains the numbers 1 to 31, (Date) runs from 1/1/2005 to 7/1/2007. What I need to do is make a query that will add up the last three months and calculate the weighted average. That average would be the forecasted value for 8/1/2007. This...
12
9145
by: denveromlp | last post by:
Hello, I'm new to Access and trying to calculate a rolling 12 month average from some time data. Each data point is a date and a measurement taken at that date. As far as I can tell, the only way to take the rolling average is to create a make-table of all the data points within the last year. Then create a query to pull out the minimum date, create a second query to pull out the maximum date, create a thrid query to pull out the...
5
3183
by: p3rk3le | last post by:
So, I'm about to do a sequential search on a table (n contents) of random numbers. I have to print the average between the number of comparisons and the contents of the table (n) and the average time for each sequential search. I wrote:
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.