Solved

Calculating time in an Access report

Posted on 2008-10-23
3
236 Views
Last Modified: 2013-11-28
I have a table in my database that I wish to report on.  The data is organized as follows:

EventDate - DATE field
EventResult - TEXT field

There are 8 possible results, and the table looks something like this....

EventDate              Result
10/23/08 12:01        RED
10/23/08 12:02        BLU
10/23/08 12:02        RED
10/23/08 12:03        RED
10/23/08 12:04        GRN
10/23/08 12:05        RED
10/23/08 12:06        YEL
10/23/08 12:08        BLU
10/23/08 12:09        GRN
10/24/08 12:01        RED
10/24/08 12:02        RED
10/24/08 12:03        BLU
10/24/08 12:03        RED
10/24/08 12:07        YEL
10/24/08 12:08        RED

What I want to do is sub-total (count) the records and also determine the amount of time passed.  

EX:

10/23/08
RED-4
BLU-2
YEL-1
GRN-1
TOTAL-8
8 minutes
AVG 1 per minute

10/24/08
RED-4
BLU-1
YEL-1
GRN-0
TOTAL-6
7 minutes
AVG .85 per minute

I have worked out most of the problem with counting the 'subtotals' in the report by using a DCOUNT funtion in the group footer (thanks to help in another post!) but I have no idea how to attack the calculation of time passed from the first event to the last event for each day.  It's simple math ...  DATE2-DATE1=TIME ELAPSED, but how to I capture what the value for the first event of each day, the last event of each day, and calculate the difference between them by group?


0
Comment
Question by:callstate
  • 2
3 Comments
 
LVL 2

Expert Comment

by:armynt4
ID: 22789979
Try using the min and max aggregate function in your report's query.

so max(Time1)-min(Time2)=time elapsed

I'll try it as well to see what i get.
0
 
LVL 6

Expert Comment

by:carazuul
ID: 22789997
Hi callstate,
DMAX - DMIN over the same criteria should work.
Regards,
carazuul
0
 
LVL 2

Accepted Solution

by:
armynt4 earned 500 total points
ID: 22790543
So on the report you may need to play with the Result field sum calculation.  
But if you list all the time values in the detail of the report you can add a field in the date's group footer with a value like......


DateDiff('n',Min([Time]),Max([Time]))


[Time] being the name of the time value field in your table/query
Creating this Time field by .... Time: Format([EventDate],'hh:mm')

Should work.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

948 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now