Link to home
Start Free TrialLog in
Avatar of babak62
babak62

asked on

Count Mysql result by hour

Hi this is my query which counts my new users registered per day.  I am trying to find out to make this to show results per hour also whitin 24 hours show how many users signed up in which hour like 11:00 10 uers and 12:00 15 etc...
Is there anyway to change this to accomplish thisi task.  Then again thanks for the help

SELECT COUNT(t_user.USERID)
FROM
t_user
WHERE
`REG_TIMESTAMP` BETWEEN '2011-04-20 00:00:00' AND '2011-04-20 23:59:59'
Avatar of Aaron Tomosky
Aaron Tomosky
Flag of United States of America image

Datepart(hour, reg_timestamp) as reghour

Group by reghour
ASKER CERTIFIED SOLUTION
Avatar of Sharath S
Sharath S
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of babak62
babak62

ASKER

Thanks for the answer I did like this

SELECT COUNT(t_user.USERID)
Datepart(hour, reg_timestamp) as reghour
FROM
t_user
WHERE
`REG_TIMESTAMP` BETWEEN '2011-04-20 00:00:00' AND '2011-04-20 23:59:59'
Group by reghour

and this was the error

[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(hour, reg_timestamp) as reghour
FROM
t_user
WHERE
`REG_TIMESTAMP` BETWEEN ' at line 2
You forgot the comma before datepart