CodeIgniter Forums
Calculate Average of time HH:MM MySql Php - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Calculate Average of time HH:MM MySql Php (/showthread.php?tid=71545)



Calculate Average of time HH:MM MySql Php - ebaad - 08-27-2018

Hello,

I have a table with time field that stores 24hr. time duration in HH:MM format, 
need help to calculate Average of time values across the table.

Example:
03:15
05:13
10:20

Any help would be appreciated.


RE: Calculate Average of time HH:MM MySql Php - php_rocs - 08-27-2018

@ebaad,

When you save average time...do you mean by the hour or hour and minutes?


RE: Calculate Average of time HH:MM MySql Php - ebaad - 08-27-2018

(08-27-2018, 03:06 PM)php_rocs Wrote: @ebaad,

When you save average time...do you mean by the hour or hour and minutes?

Thanks, I am looking to get average time in HH:MM format to show the Min, Max and Average time to respond on events.


RE: Calculate Average of time HH:MM MySql Php - luiszagaceta - 08-27-2018

(08-27-2018, 03:22 PM)ebaad Wrote:
(08-27-2018, 03:06 PM)php_rocs Wrote: @ebaad,

When you save average time...do you mean by the hour or hour and minutes?

Thanks, I am looking to get average time in HH:MM format to show the Min, Max and Average time to respond on events.

Hello, I hope this helps you:

SELECT SEC_TO_TIME(AVG(TIME_TO_SEC(`hours`))) FROM `table_name`

[Image: tabla_1.PNG]


[Image: tabla_2.PNG]