8

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

Nathan H
  • 48,033
  • 60
  • 165
  • 247

3 Answers3

10

Should be able to

GROUP BY date(actionTime)

See this for more info.

Benjamin Cox
  • 6,090
  • 21
  • 19
5

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
  • 1,897
  • 12
  • 13
  • 1
    Google is easy to use. But the whole point of stackoverflow is getting a peer-reviewed solution – Ken Dec 16 '09 at 22:54
0

Yep, use MySQL's DATE() function:

SELECT * FROM your_table GROUP BY DATE(actionTime);
Jordan Running
  • 102,619
  • 17
  • 182
  • 182