MySQL: Getting "busiest" or "most popular" hour from a datetime field?

Posted by k00k on Stack Overflow See other posts from Stack Overflow or by k00k
Published on 2010-03-18T16:25:51Z Indexed on 2010/03/18 16:41 UTC
Read the original article Hit count: 329

Filed under:
|
|
|

Consider the following table which has the fields - id (int) and date_created (datetime):

id       date_created

 1       2010-02-25 12:25:32
 2       2010-02-26 13:40:37
 3       2010-03-01 12:02:22
 4       2010-03-01 12:10:23
 5       2010-03-02 10:10:09
 6       2010-03-03 12:45:03

I want to know the busiest/most popular hour of the day for this set of data. In this example, the result I'm looking for would be 12.

Ideas?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about datetime