Reputation: 479
I have a mysql table that has a column for "date time" in TIMESTAMP format. Is there a way to group the rows by day using that column? And in an SQL query, not grouping them in php.
Upvotes: 3
Views: 7727
Reputation: 79584
If you mean you have a standard DATETIME column, you can group by using one of the functions described here.
For instance:
GROUP BY DATE(datetime_column);
If you actually have a TEXT or VARCHAR column (your answer doesn't specify), then you'll need to convert it to to a date first:
GROUP BY DATE(STR_TO_DATE(datetime_column));
Upvotes: 3
Reputation: 522081
Assuming your column is one of the Date and Time types:
SELECT ... GROUP BY DATE(`datetimecolumn`)
Upvotes: 8