当时间精确到秒的指标和时间精确到日的时间进行对比是恒不等于的,但是可以判断大于或者等于的情况。
举个例子,指标【时间精确到秒】
select 时间精确到秒
from table
where 时间精确到秒<= to_date('2013-11-20 ', 'yyyy-MM-dd ')
and 时间精确到秒 >= to_date('2013-11-20 ', 'yyyy-MM-dd ')
明显数据查询2013-11-20那天没有数据,而如果sql如下写发现数据库中是存在数据的。
select 时间精确到秒
from table
where to_date(to_char(时间精确到秒,'yyyy-MM-dd'),'yyyy-MM-dd') <= to_date('2013-11-21 ', 'yyyy-MM-dd ')
and to_date(to_char(时间精确到秒,'yyyy-MM-dd'),'yyyy-MM-dd') >= to_date('2013-11-20 ', 'yyyy-MM-dd ')