Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cast DATETIME as a DATE in mysql?

My query is this. I have a bunch of entries and i want to group them by date. But instead of having date in my database, I have a datetime field. What do I do?

select * from follow_queue group by follow_date cast follow_date as date 

That's not working.

like image 737
Zack Burt Avatar asked Sep 23 '09 22:09

Zack Burt


People also ask

How do I get just the date from a timestamp?

You can use date(t_stamp) to get only the date part from a timestamp. Extracts the date part of the date or datetime expression expr.


1 Answers

Use DATE() function:

select * from follow_queue group by DATE(follow_date) 
like image 162
ChssPly76 Avatar answered Oct 28 '22 19:10

ChssPly76