sabari k sabari k - 1 month ago 10
MySQL Question

How do i write Group By query for datetime field in mysql

I need to group by only date without time from datetime field in table.What can i do friends?

Here My Table field is,

enter image description here

My Mysql query is,

select *,count(ord_number) as ord from tbl_order_details inner join tbl_users on tbl_users.user_id=tbl_order_details.user_id where 1=1 group by ord_date order by ord asc

Answer

You can do it by DATE()

Example -

group by DATE(ord_date)

Try this

select *,count(ord_number) as ord from tbl_order_details inner join tbl_users on tbl_users.user_id=tbl_order_details.user_id  where 1=1 group by DATE(ord_date) order by ord asc