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)