ms-accessaveragecalculated-field

Calculating the average time between StartTime and EndTime in VBA or in a calculated control. Then getting an average for many records


I want to get the average time between StartTime and EndTime in VBA or in a calculated control. Then get an average for many records. I am using Access to build controls on a form that will show the average in the form-footer so that when a user changes the form filter the [AvgTimeOnSite] control will add up the [TimeOnSite] controls from above record sets and display an average of minutes that each driver spends at a particular plant when making deliveries.

I am looking to get the average time in minutes that a delivery drivers spend at a particular plant getting loaded or unloaded.

enter image description here


Solution

  • Use DateDiff("n", ReceivingTime, DepartingTime) to calculate the minutes spent.

    Then use Sum and Avg in the form's footer as control sources:

    =Sum(DateDiff("n",ReceivingTime,DepartingTime)) 
    =Avg(DateDiff("n",ReceivingTime,DepartingTime))