Let’s say we’re tracking the times when a user is performing a certain action, and we want to know the average time between said actions.
For example, if the user performed this action at these times:
- today, 1 PM
- today, 3 PM
- today, 6 PM
The result would be 2.5 hours.
I actually have solved this already, but I felt my solution was more complicated than necessary. I’ll post it as an answer.
It seems that you are basically looking for Max – Min divided by Count.
Make sure you check that there is more than one DateTime.
Update: Even more accurate if you use Ticks.