如何在 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
How to cast DATETIME as a DATE in mysql?
提问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 Abhi
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
http://www.tutorialspoint.com/mysql/mysql-date-time-functions.htm
http://www.tutorialspoint.com/mysql/mysql-date-time-functions.htm
use Date function directly. Hope it works
直接使用Date函数。希望它有效