Sql

Asked • 05/09/19

MySQL/SQL: Group by date only on a Datetime column?

Having a table with a column like: `mydate DATETIME` ... I have a query such as: SELECT SUM(foo), mydate FROM a_table GROUP BY a_table.mydate; This will group by the full `datetime`, including hours and minutes. I wish to make the group by, only by the date `YYYY/MM/DD` not by the `YYYY/MM/DD/HH/mm`. Anyone know how to do this? I can still do it (as I am atm), dynamically in my code, but I'm cleaning trash code and this can be made through the SQL I just can't find out how :(.

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.