How to write a Group By query for a datetime field in mysql

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

Here is the My Table field,

enter image description here

My Mysql query,

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
+4
source share
2 answers

You can do it with DATE ()

Example -

group by DATE(ord_date)

Try

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
+3
source

use the DATE () function

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
+1
source

Source: https://habr.com/ru/post/1659899/


All Articles