I am trying to use Access to generate a report that will list the average time difference between two events by month.
At first I tried using a calculated field in my query then group by month in the report and use an unbound control and the Avg() function in the group footer. My formula in the calculated field looked like this:
Mutual Aid Response Time: Format(tblMutualAid.FirstDispatchTime-1-tblMutualAid.OnSceneTime,"hh:nn:ss")
I had to use the -1 to account for those instances where the two times spanned midnight. Everything work up until this point. The problems started when I tried to average the results by month. I used =Avg([Mutual Aid Response Time]) in a text box in the group footer section. When I previewed the report I got a data type mismatch error.
I assumed that this was caused by using the Format function for the calculated field in the query. So I tried a different tactic. I removed the format function and use this for the calculated field:
Mutual Aid Response Time: tblMutualAid.FirstDispatchTime-1-tblMutualAid.OnSceneTime
Then I applied Avg and format functions to the results. This method took care of the type mismatch error, but it does not report the correct result if one of the records for that month has values that span midnight.
The time fields I am working with have not day information associated with them. By this I mean that when I use the long date format, all the record have the same day and year (1899 IIRC).
Does anyone know of a way around either of these issues?
Thank you in advance.
Timoteo
At first I tried using a calculated field in my query then group by month in the report and use an unbound control and the Avg() function in the group footer. My formula in the calculated field looked like this:
Mutual Aid Response Time: Format(tblMutualAid.FirstDispatchTime-1-tblMutualAid.OnSceneTime,"hh:nn:ss")
I had to use the -1 to account for those instances where the two times spanned midnight. Everything work up until this point. The problems started when I tried to average the results by month. I used =Avg([Mutual Aid Response Time]) in a text box in the group footer section. When I previewed the report I got a data type mismatch error.
I assumed that this was caused by using the Format function for the calculated field in the query. So I tried a different tactic. I removed the format function and use this for the calculated field:
Mutual Aid Response Time: tblMutualAid.FirstDispatchTime-1-tblMutualAid.OnSceneTime
Then I applied Avg and format functions to the results. This method took care of the type mismatch error, but it does not report the correct result if one of the records for that month has values that span midnight.
The time fields I am working with have not day information associated with them. By this I mean that when I use the long date format, all the record have the same day and year (1899 IIRC).
Does anyone know of a way around either of these issues?
Thank you in advance.
Timoteo