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. :)

Link to comment
Share on other sites

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
;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.