如何在 mysql 中将 DATETIME 转换为 DATE? [英] How to cast DATETIME as a DATE in mysql?

查看:114
本文介绍了如何在 mysql 中将 DATETIME 转换为 DATE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的查询是这样的.我有一堆条目,我想按日期对它们进行分组.但是我的数据库中没有日期,而是有一个日期时间字段.我该怎么办?

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

这行不通.

推荐答案

使用 DATE() 函数:

Use DATE() function:

select * from follow_queue group by DATE(follow_date)

这篇关于如何在 mysql 中将 DATETIME 转换为 DATE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆