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. -
-
Public Function WorkingDays2(StartDate As Date, EndDate As Date) As Integer
-
'....................................................................
-
' Name: WorkingDays2
-
' Inputs: StartDate As Date
-
' EndDate As Date
-
' Returns: Integer
-
' Author: Arvin Meyer
-
' Date: May 5,2002
-
' Comment: Accepts two dates and returns the number of weekdays between them
-
' Note that this function has been modified to account for holidays. It requires a table
-
' named tblHolidays with a field named HolidayDate.
-
'....................................................................
-
On Error GoTo Err_WorkingDays2
-
Dim intCount As Integer
-
Dim rst As DAO.Recordset
-
Dim DB As DAO.Database
-
Set DB = CurrentDb
-
Set rst = DB.OpenRecordset("SELECT [HolidayDate] FROM tblHolidays", dbOpenSnapshot)
-
-
'StartDate = StartDate + 1
-
'To count StartDate as the 1st day comment out the line above
-
intCount = 0
-
-
Do While StartDate <= EndDate
-
rst.FindFirst "[HolidayDate] = #" & StartDate & "#"
-
If Weekday(StartDate) <> vbSunday And Weekday(StartDate) <> vbSaturday Then
-
If rst.NoMatch Then
-
intCount = intCount + 1
-
End If
-
StartDate = StartDate + 1
-
Loop
-
-
WorkingDays2 = intCount
-
Exit_WorkingDays2:
-
Exit Function
-
Err_WorkingDays2:
-
Select Case Err
-
Case Else
-
MsgBox Err.Description
-
Resume Exit_WorkingDays2
-
End Select
-
End Function
-
1 9187 NeoPa 32,578
Recognized Expert Moderator MVP
Perhaps you wouldn't mind rewriting the question with some punctuation.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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:
|
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...
|
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,...
|
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.
|
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.
| |
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...
|
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...
|
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...
|
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:
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |