MySQL日期比较问题 [英] MySQL date comparison issue
本文介绍了MySQL日期比较问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
2011-02-21 14:40:03
但是,我只需要比较这个日期和时间的日期,即:
2011-02-21
解决方案
更好的解决方案是使用 WHERE col> ='2011-02-21' AND col '2011-02-22'
,所以如果有一个存在,MySql可以使用索引。
I have the date in 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.
这篇关于MySQL日期比较问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文