AV1611 Posted July 31, 2007 Share Posted July 31, 2007 I have a table with dates in a varchar field like this: 2006-06-23 2007-01-02 etc. I need to group by based on year and month only I am using mysql within a php 5 script. Can someone help? Thanks select * from table where date like ??? or select * from table group by ??? Thanks. Link to comment https://forums.phpfreaks.com/topic/62584-solved-select-by-portion-of-a-date/ Share on other sites More sharing options...
hitman6003 Posted July 31, 2007 Share Posted July 31, 2007 Try something like: SELECT * FROM table ORDER BY date_field GROUP BY YEAR(date_field), MONTH(date_field) Link to comment https://forums.phpfreaks.com/topic/62584-solved-select-by-portion-of-a-date/#findComment-311541 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.