I'm trying to write a SQL statement where it will return the number of record per day.
This my table
id | ip | date
----------------------------------------
1 136.196.41.91 2017-01-01 11:08:14
2 28.158.146.198 2017-01-01 11:08:15
3 209.140.42.236 2017-01-01 11:08:16
4 241.184.227.171 2017-01-02 11:08:17
5 6.183.99.169 2017-01-02 11:08:18
6 105.18.254.15 2017-01-03 11:08:19
expected result something similar to:
2017-01-01: 3
2017-01-02: 2
2017-01-03: 1
I m trying this
select date, count(id)
from demo
WHERE date >=dateadd(day,datediff(day,0,GetDate())-7,0)
GROUP BY date
But for some reason i'm getting this error in "phpmyadmin"
Error
SQL query: Documentation
select date, count(id)
from demo
WHERE date >=dateadd(day,datediff(day,0,GetDate())-7,0)
GROUP BY date LIMIT 0, 25
MySQL said: Documentation
#1582 - Incorrect parameter count in the call to native function 'datediff'
I can't find what I'm doing wrong.
And i thought it might be from the date format, so i changed it into date only but with no luck.
Please advise.