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
count website visitors
Ask by marcel ethan
Updated 31 Dec 2012
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