-- 大概就是这样,没测试 where col between to_date('2014/09/01','yyyy-mm-dd hh24:mi:ss') and to_date('2014/10/01 23:59:59','yyyy-mm-dd hh24:mi:ss') and to_char(col,'hh24:mi:ss') between '08:00:00' and '15:00:00'
真是感谢,查到了是使用to_char,但是没想到是在后面直接加上就行了,我还把to_date改了
create table t1 ( id number, createdate date )insert into t1 values (1,to_date('2014-12-25 10:36:55','yyyy-mm-dd hh24:mi:ss')) insert into t1 values (2,to_date('2014-12-25 22:36:55','yyyy-mm-dd hh24:mi:ss')) insert into t1 values (3,to_date('2014-12-20 22:36:55','yyyy-mm-dd hh24:mi:ss'))select * from t1 where createdate > to_date('2014-12-24', 'yyyy-mm-dd') and createdate < to_date('2014-12-26', 'yyyy-mm-dd') and to_char(createdate, 'hh24') >= '20' and to_char(createdate, 'hh24') <= '22'
-- 大概就是这样,没测试
where col between to_date('2014/09/01','yyyy-mm-dd hh24:mi:ss') and to_date('2014/10/01 23:59:59','yyyy-mm-dd hh24:mi:ss')
and to_char(col,'hh24:mi:ss') between '08:00:00' and '15:00:00'
create table t1
(
id number,
createdate date
)insert into t1 values (1,to_date('2014-12-25 10:36:55','yyyy-mm-dd hh24:mi:ss'))
insert into t1 values (2,to_date('2014-12-25 22:36:55','yyyy-mm-dd hh24:mi:ss'))
insert into t1 values (3,to_date('2014-12-20 22:36:55','yyyy-mm-dd hh24:mi:ss'))select *
from t1
where createdate > to_date('2014-12-24', 'yyyy-mm-dd')
and createdate < to_date('2014-12-26', 'yyyy-mm-dd')
and to_char(createdate, 'hh24') >= '20'
and to_char(createdate, 'hh24') <= '22'