select * from ms_cf01 a where a.kfrq between to_date('20100101 180000','yyyymmdd hh24miss')
and to_date('20101231 180000','yyyymmdd hh24miss')
and to_char(a.kfrq,'hh24miss') between '180000' and '240000'
主要用到 to_char,to_date对时间字段的转换方法,具体使用方法可baidu
如果这么查询,主要是第2个条件无法用上索引,所以最好的方式是在涉及表的时候将该字段拆成2个字段 日期 ,时间,并用整形表示
select * from ms_cf01
where to_number(to_char(kfrq,'yyyymmdd')) between 20100101 and 20121231 --限定日期
and to_number(to_char(kfrq,'hh24miss')) between 180000 and 235959 --限定时间
select * from ms_cf01 where datepart(yy,kfrq)=2010 and datePart(hh,kfrq)>=18 and datepart(hh,kfrq)<=24
between