我有一个表,其中包含ID的列表(int)和创建ID的日期(日期时间)。MySQL日期匹配错误?
一个ID尤其是被创造:
2010-12-31 9点45分29秒
当我运行下面的查询,不返回任何结果:
select * from information where creation = '2010-12-31'
是什么给了?我认为这是因为时间戳(它不匹配2010-12-31 00:00:00),但似乎它应该作为一般'日期'。
我有一个表,其中包含ID的列表(int)和创建ID的日期(日期时间)。MySQL日期匹配错误?
一个ID尤其是被创造:
2010-12-31 9点45分29秒
当我运行下面的查询,不返回任何结果:
select * from information where creation = '2010-12-31'
是什么给了?我认为这是因为时间戳(它不匹配2010-12-31 00:00:00),但似乎它应该作为一般'日期'。
不,不应该。尝试运行
select * from information where creation LIKE '2010-12-31%';
或
select * from information where DATE(creation) = '2010-12-31'
试试这个:
select * from information where DATE_FORMAT(creation,'%Y-%m-%d') = '2010-12-31'
重复http://stackoverflow.com/questions/4973268/mysql-date-and-datetime-problem – Ergec