473,387 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Average number of workdays per month from table

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 9172
NeoPa
32,556 Expert Mod 16PB
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
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),...
1
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...
4
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...
6
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...
3
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
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...
10
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...
12
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...
5
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.