webbgroup Posted January 16, 2003 Share Posted January 16, 2003 How would you group by dates in a table where the date shows up like this: \"2003-01-15 13:05\" I already tried something like this without much success. select time as TIME, count(*) as posts from table group by time REGEXP \"2003-01-%\"; Any suggestions?? Quote Link to comment https://forums.phpfreaks.com/topic/53-tricky-group-by-mysql-question/ Share on other sites More sharing options...
pallevillesen Posted January 16, 2003 Share Posted January 16, 2003 mysql> SELECT DATE_FORMAT(\'1997-10-04 22:23:00\', \'%Y-%m-%d\'); +------------------------------------------------+ | DATE_FORMAT(\'1997-10-04 22:23:00\', \'%Y-%m-%d\') | +------------------------------------------------+ | 1997-10-04 | +------------------------------------------------+ 1 row in set (0.00 sec) mysql> Use the date_format consistently throughout the query. I think you should read the mysql manual about date functions: http://www.mysql.com/doc/en/Date_and_time_..._functions.html P., denmark Quote Link to comment https://forums.phpfreaks.com/topic/53-tricky-group-by-mysql-question/#findComment-146 Share on other sites More sharing options...
webbgroup Posted January 16, 2003 Author Share Posted January 16, 2003 YOur the man! Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/53-tricky-group-by-mysql-question/#findComment-152 Share on other sites More sharing options...
effigy Posted January 16, 2003 Share Posted January 16, 2003 bio keeps the sql kicking Quote Link to comment https://forums.phpfreaks.com/topic/53-tricky-group-by-mysql-question/#findComment-155 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.