我遇到了带有日期条件的select queryI(下面)的问题。查询没有给出正确的结果,我不知道为什么?
请帮助我,谢谢你提前感谢。数据库中的Created_Date字段在2013-01-01到2013-01-31之间有价值
SELECT * FROM (`cms_product`) WHERE `cms_product`.`Created_Date` >= 2013-01-01
and `cms_product`.`Created_Date` <= 2013-01-31 ;
Created_Date字段位于Datetime。
答案 0 :(得分:5)
您可能希望在此处使用BETWEEN运算符。
SELECT * FROM (`cms_product`) WHERE `cms_product`.`Created_Date` BETWEEN '2013-01-01 00:00:00.000' AND ' 2013-01-31 23:59:59.997'
答案 1 :(得分:1)
试试这个:
SELECT * FROM cms_product WHERE Created_Date >= '2013-01-01' AND Created_Date <= '2013-01-31';
答案 2 :(得分:0)
SELECT * FROM `cms_product` WHERE `Created_Date` BETWEEN '2013-01-01' AND '2013-01-31';
答案 3 :(得分:0)
SELECT * FROM cms_product WHERE DATE(Created_Date) BETWEEN '2013-01-01' AND '2013-01-31';