问题描述
- 大神们oracl 中显示两个时间段中的所有整点时间呢,
-
例如:2015-05-16 07:20:49 到 2015-05-21 08:30:00 我要得到的时间为 2015-05-16 08:00:00, 2015-05-16 09:00:00,2015-05-16 10:00:00。。。。2015-05-21 07:00:00 ,2015-05-21 08:00:00
解决方案
select to_char(to_date('2015-03-08 08:00:00','yyyy-mm-dd hh24:mi:ss')+1,'yyyy-mm-dd hh24:mi:ss') from dual
看懂这个例子你就知道怎么做了吧
解决方案二:
select trunc(to_date('2015-05-16 07:20:49', 'yyyy-MM-dd HH24:mi:ss') +
(rownum - 1) / 24,
'HH')
from dual
connect by rownum <=
(to_date('2015-05-21 08:30:00', 'yyyy-MM-dd HH24:mi:ss') -
to_date('2015-05-16 07:20:49', 'yyyy-MM-dd HH24:mi:ss')) * 24 + 1
解决方案三:
select trunc(to_date('2015-05-16 07:20:49', 'yyyy-MM-dd HH24:mi:ss') +
(rownum - 1) / 24,
'HH')
from dual
connect by rownum <=
(to_date('2015-05-21 08:30:00', 'yyyy-MM-dd HH24:mi:ss') -
to_date('2015-05-16 07:20:49', 'yyyy-MM-dd HH24:mi:ss')) * 24 + 1
解决方案四:
select trunc(to_date('2015-05-16 07:20:49', 'yyyy-MM-dd HH24:mi:ss') +
(rownum - 1) / 24,
'HH')
from dual
connect by rownum <=
(to_date('2015-05-21 08:30:00', 'yyyy-MM-dd HH24:mi:ss') -
to_date('2015-05-16 07:20:49', 'yyyy-MM-dd HH24:mi:ss')) * 24 + 1