This is an example for you, rest is upto you
create table def(d DATETIME);
-> insert into def values
-> ('2012-01-02 12:10:11'),
-> ('2012-01-02 12:12:11'),
-> ('2012-01-02 01:12:11'),
-> ('2012-01-02 01:32:11');
SELECT COUNT(*) FROM def GROUP BY MID(d, 1, 13);
Find out rest by yourself