MySQL: GROUP BY on DATETIME field
Posted by Em on 18 May, 2008
5 Comments
This item was filled under [ MySQL ]
Often webmasters want to sort out data on the basis of Dates when timestamp is stored as datetime in MySQL. To obtain the desired result, simply query:
SELECT DATE_FORMAT(MyDate, '%d %M %Y') AS Date, COUNT(*) AS numRows FROM Table1 GROUP BY Date;