如何在 mysql 中将 DATETIME 转换为 DATE?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1468807/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 14:09:06  来源:igfitidea点击:

How to cast DATETIME as a DATE in mysql?

mysqldatetimedate

提问by Zack Burt

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.

这是行不通的。

回答by ChssPly76

Use DATE()function:

使用DATE()功能:

select * from follow_queue group by DATE(follow_date)