oracle 中如何选择每天某个时间段中的数据,如每天7点到11点的数据?

如题所述

select * from 表
where to_char(TempDate,'hh24:mi') between '00:00' and '11:00'
我在PLSQL里面必须这样写,只写小时会仅限制到最后那天的11点。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-04-18
select * from table t where to_char(t.date, 'hh24:mi:ss') >= '07:00:00' and to_char(t.date, 'hh24:mi:ss') <= '11:00:00'本回答被网友采纳
第2个回答  推荐于2017-08-20
1,表里需要有一个date类型的字段,假设字段名为TempDate
2,实行下面的sql文
select * from 表
where to_char(TempDate,'hh24') between '7' and '11'
--这里用的是24小时计时方式本回答被网友采纳
第3个回答  2019-01-16
你可以把时间全部to_char成字符串类型,然后根据长度判断,如果是只精确到天的话,长度肯定是10,把长度为10的字段修改为精确到每天8点。
to_date(to_char(qsrq,'yyyy-mm-dd')||
08:00:00,'yyyy-mm-dd
hh24:mi:ss')
第4个回答  2011-04-18
select * from table where to_char(datecolumn,'hh24') between '7' and '11'
相似回答