Mysql从datetime剥离时间组件 [英] Mysql strip time component from datetime

查看:80
本文介绍了Mysql从datetime剥离时间组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Mysql中进行日期比较,而不考虑时间部分,即我需要将2008-11-05 14:30:00转换为2008-11-05

I need to do a date comparison in Mysql without taking into account the time component i.e. i need to convert '2008-11-05 14:30:00' to '2008-11-05'

目前我正在这样做:

SELECT from_days(to_days(my_date))

有没有正确的方法?

推荐答案

是的,请使用 date 函数:

SELECT date(my_date)

这篇关于Mysql从datetime剥离时间组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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