hey, I am trying to find Min, Max and average time. My time is saved hh:mm. Can I use the Statistic Calculator?
min, max and median time
Best answer by mark2atsafe
Nice question. You can use the StatisticsCalculator to find the maximum and minimum time quite easily, by converting the times to FME time format first, using the DateTimeConverter:
Then apply the StatisticsCalculator and convert the results back using a second DateTimeConverter.
That will work fine for the minimum and maximum times.
However... that won't really work for average times. That's because hours have 60 minutes, not 100. For example if I have 13:45 and 14:25 then the average is 13:85. The DateTimeConverter can easily handle the overflow, but it returns 14:25 (because the StatsCalculator rolls over at 13.99, not 13.59).
So, if you really need averages, it'll need a bit more work. You'll need to use the DateTimeConverter to get the minutes only (%M) then convert them to a fraction of an hour with the ExpressionEvaluator. Then add it back to the hours (as a fraction) and use the StatisticsCalculator on that.
So 13:45 becomes 13+(45/60) = 13.75 and 14:25 becomes 14+(25/60) = 14.412, the mean of which is 14.081
Now you need to extract the .081, multiple by 60 to get minutes, and patch it back onto the hours, including rounding it off and adding leading zeros:
So the average = 14:(0.081*60) = 14:05
In short, max and min are very simple to do. Average is more complicated. Unless anyone else can think of a simpler method...
[Edit: DateTimeConverter, not DateTimeCalculator]
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.