Jump to content

[SOLVED] group visits by month using range of timestamps, then by unique visits?


ultrus

Recommended Posts

Hello,

I'm creating a basic website traffic stat page, and am trying to decide the best way to store the visit times, and how to group the time/visit counts by month to show on the on this page.

 

Should I use MySQL's built in TIMESTAMP, or should I use 10 digit timestamps instead? As people visit the single page website, their IP address is logged with the timestamp. How would I group these visits by month, then possibly by ip for unique visits?

 

Thanks much for the advice. :)

TIMESTAMP type is OK, DATE type is OK too.

Your query to get number of visits per month is correct.

To get number of visits per month per IP modify it like this:

SELECT
   DATE_FORMAT(bdate, '%Y-%m') ym
   , ipNumber
   , COUNT(*)
FROM foo
GROUP BY
   ym, ipNumber
ORDER BY
   ym, ipNumber
;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.