开发者

MySQL date comparison issue

开发者 https://www.devze.com 2023-02-15 16:30 出处:网络
I have the date in 开发者_Go百科this format in mySQL databse: 2011-02-21 14:40:03 But i have to compare only datepart of this dateandtime i.e:

I have the date in 开发者_Go百科this format in mySQL databse:

2011-02-21 14:40:03

But i have to compare only datepart of this dateandtime i.e:

2011-02-21

How???


A better solution is to use WHERE col >= '2011-02-21' AND col < '2011-02-22', so MySql can use a index if there is one present.


... where date(datetime_column) = '2011-02-21'

Here is the documentation

0

精彩评论

暂无评论...
验证码 换一张
取 消