Answer the question
In order to leave comments, you need to log in
Average time on site?
Good afternoon. Guys how to calculate the average time of activity on the site.
Table
id_user: - User ID
visit_date: - Date when the user entered
last_visit: - Date when the user left
[
id_user: 1,
visit_date: 'Зашел',
last_visit: 'Ушел'
],[
id_user: 1,
visit_date: 'Зашел',
last_visit: 'Ушел'
],[
id_user: 1,
visit_date: 'Зашел',
last_visit: 'Ушел'
],[
id_user: 2,
visit_date: 'Зашел',
last_visit: 'Ушел'
],[
id_user: 3,
visit_date: 'Зашел',
last_visit: 'Ушел'
],[
id_user: 1,
visit_date: 'Зашел',
last_visit: 'Ушел'
],
Answer the question
In order to leave comments, you need to log in
Walk through the array, calculate the difference last_visit - visit_date in seconds for a particular user. Collect all durations in an array and calculate the median.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question