Home > DeveloperSection > Forums > count website visitors
marcel ethan
marcel ethan

Total Post:105

Points:735
Posted on    December-31-2012 12:33 AM

 MSSQL Server MSSQL Server 
Ratings:


 1 Reply(s)
 1070  View(s)
Rate this:
Hi every one,

In my web project i want to store website visitors

I have a table to store website visitor count bellow

id   date          ip           
-----------------------------
1    1-1-2012     195.165.1.2
2    1-1-2012     195.165.1.3
3    12-2-2012    195.165.1.8

and i want a sql query for get count of each month of current year.

Thanks in advance


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    December-31-2012 8:21 AM

Hi Marcel Ethan

You can use below sql query for getting IP information


SELECT  MONTHNAME(STR_TO_DATE(date, '%c-%e-%Y')) `monthName`, COUNT(*) totalCount
FROM    tableName
WHERE   YEAR(STR_TO_DATE(date, '%c-%e-%Y')) = YEAR(CURDATE())
GROUP BY  MONTHNAME(STR_TO_DATE(date, '%c-%e-%Y'))

you can use another query

"select month(date),count(distinct ip) from visitors where date>='$y-01-01' and date<'$y-12-31' group by 1"

I hope it resolve your problem


Don't want to miss updates? Please click the below button!

Follow MindStick