Hi all,

I have table in SQL which stores the time the user entered my site and the time they left (updated via AJAX). I am using the unix timestamp, not a regular timestamp. With this I have been able to easily figure out the average length of time a user spends on my site, but I also want to be able to work out the average number of hits per day (from the beginning of my records), the average number of hits per week and per month.

I can't actually figure out how to do this with unix timestamps. I'm aware this can be done in SQL or PHP, and would favour an SQL solution if possible. I've been given one possible solution from Stackoverflow, but I can't figure out how to implement it with my current database. The code I was given is:

PHP Code:
select date(from_timestamp(timestamp_start)), count(*)
from t
group by date
(from_timestamp(timestamp_start)) 
This is table structure (example data):

PHP Code:
+----------------+----------------+----------------+----------------+
start          end            unique_id      id             |
+----------------+----------------+----------------+----------------+
1358789867     1358789872     | (hash here)    | 65             |
+----------------+----------------+----------------+----------------+
1358789966     1358789972     | (hash here)    | 66             |
+----------------+----------------+----------------+----------------+
1358789998     1358790003     | (hash here)    | 67             |
+----------------+----------------+----------------+----------------+ 
Help much appreciated, thank you.