0

I have a mysql table to store users registration . I'd like to calculate the average time between users registration time

my table is something like this,

|id|userid_id|name  |time               |
-----------------------------------------
|1 |  100    |xxxxxx|2016-01-25 00:27:16|
|2 |  101    |Xyyyyy|2016-01-26 05:10:04|
|3 |  102    |gggggg|2016-01-27 03:16:13|
|4 |  103    |hhhhhh|2016-01-28 00:11:33|
|5 |  104    |eeeeee|2016-01-29 00:30:16|
|6 |  105    |ssssss|2016-01-30 07:27:16|
|7 |  106    |rrrrrr|2016-01-31 01:20:12|
|8 |  107    |oooooo|2016-01-31 03:31:04|
|9 |  108    |tttttt|2016-01-31 04:55:00|

i need to know the average time between users registration mysql query . also if i use UNIXtimestamp

i need below in MySQL Query Column time to array (as timestamp). (12,16,32,65,99) Loop to calculate sum of $array: array[6]-array[5],array[5] - array[4],,array[4] - array[3] ...... etc... $average = array_sum($array) / count($array);

Mohamed
  • 1
  • 1
  • [http://stackoverflow.com/questions/2722214/mysql-get-average-of-time-differences] visit this link – Nishant Nair Jan 12 '17 at 12:07
  • 2
    Possible duplicate of [MySQL: Get average of time differences?](http://stackoverflow.com/questions/2722214/mysql-get-average-of-time-differences) – PereG Jan 12 '17 at 12:17

1 Answers1

0
  1. Column time to array (as timestamp). (12,16,32,65,99)
  2. Loop to calculate: array[6]-array[5],array[5] - array[4]......
  3. Save results of loop in another array
  4. $average = array_sum($array) / count($array);
marko_b123
  • 300
  • 2
  • 14