数据库里的内容:
2013-11-11
2013-11-12
select b.createtime from t_cc b where b.createtime >= to_date('2013-11-11', 'yyyy-MM-dd') and b.createtime <= to_date('2013-11-12', 'yyyy-MM-dd');
查询出的结果 :2013-11-11
select b.createtime from t_cc b where to_char(b.createtime, 'yyyy-MM-dd') >= '2013-11-11' and to_char(b.createtime, 'yyyy-MM-dd')<= '2013-11-12';
查询出的结果:
2013-11-11
2013-11-12
结论:to_date比较,它会精确到时分秒,而字符串它是没有时分秒的,自动默认00:00:00,所以,比较没有时分秒的日期,最好把它转换为字符串来比较。