views:

244

answers:

3

In MySQL, let's say I have a table with a column called 'actionTime' declared as a 'datetime' (YYYY-MM-DD HH:MM:SS).

Is there an easy way to use "GROUP BY actionTime" but only use the 'date' part of the 'datetime'?

Thanks

+4  A: 

Ahh Google .. so easy to use.
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date

mysql> SELECT DATE('2003-12-31 01:02:03');
        -> '2003-12-31'
BryanD
Google is easy to use. But the whole point of stackoverflow is getting a peer-reviewed solution
Ken
A: 

Yep, use MySQL's DATE() function:

SELECT * FROM your_table GROUP BY DATE(actionTime);
Jordan
+2  A: 

Should be able to

GROUP BY date(actionTime)

See this for more info.

Benjamin Cox