I have a huge list of times (HH:MM:SS) and I know that if I wanted to create an average I could separate the Hours, Seconds, and Minutes and average each one and then concatenate them back together. However I feel that there must be a better way to do that. Does anyone know of a better way to do this?
Thanks!
Advertisement
Answer
You don’t want to “average” times on hours, minutes and seconds this way:
00:59:00 01:01:00
average clearly to 01:00:00
, but not with the logic you presented.
Instead convert all your time intervals into seconds, calculate the average and convert back to HH:MM:SS
.
00:59:00 -> 3540 seconds 01:01:00 -> 3660 seconds ============ average: 3600 seconds converted to HH:MM:SS -> 01:00:00