在写按时间段查询的sql语句的时候 一般我们会这么写查询条件:
where date>=\'2010-01-01\' and date<=\'2010-10-1\'。
但是在实执行Sql时些语句会转换成这样:
where date>=\'2010-01-01 0:00:00\' and date<=\'2010-10-1:0:00:00\',再看这个条件的话,也许就会有些明白,
那就是\'2010-10-1 0:00:00\' 之后的数据例如(\'2010-10-1:08:25:00\')查不到,也就是说2010-10-1的数据查不到。
知道原因了可以修改查询条件为:
where date>=\'2010-01-01\' and date<=\'2010-10-1 23:59:59\' 或 where date>=\'2010-01-01\' and date<=\'2010-10-2\'。