--例如查询2010年8月7日之2010年9月10日间的数据 select * from tablename where columnname between to_date('20100807','yyyymmdd') and to_date('20100910','yyyymmdd')
这就是取5月份的 dt>to_date('2010-05-01','yyyy-mm-dd') and dt<to_date('2010-05-31 23:59:59','yyyy-mm-dd hh24:mi:ss')
也可以这样,是一种方式,不过效率上不如1楼,数据量不太大的话就没有多大区别了 --例如查询2010年8月7日之2010年9月10日间的数据 select * from tablename where to_char(columnname,'yyyymmdd') between '20100807' and '20100910'
--例如查询2010年8月7日之2010年9月10日间的数据
select * from tablename
where columnname between to_date('20100807','yyyymmdd')
and to_date('20100910','yyyymmdd')
dt>to_date('2010-05-01','yyyy-mm-dd') and dt<to_date('2010-05-31 23:59:59','yyyy-mm-dd hh24:mi:ss')
--例如查询2010年8月7日之2010年9月10日间的数据
select * from tablename
where to_char(columnname,'yyyymmdd') between '20100807' and '20100910'