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
209331-Dec-2012
Updated on 31-Dec-2012
AVADHESH PATEL
31-Dec-2012Hi 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