Posts Tagged ‘mysql group by on datetime field’

MySQL: GROUP BY on DATETIME field

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;

Continue reading...