1.获取当前时间的前24小时的各小时时间段
select to_date(to_char(sysdate -(rownum - 1) / 24,’yyyy-mm-dd hh24’) || ‘:00:00’,’yyyy-mm-dd hh24:mi:ss’) totalDate
from dual
connect by rownum <= 24 order by totalDate
===========================================================
2.获取某天的0点到24点的各小时时间段
select to_date(‘2018-04-12’, ‘yyyy-mm-dd’) + (rownum - 1) / 24 times
from dual
connect by level <= 24
本文介绍两种SQL查询方法:一是获取当前时间前24小时内的每个小时的时间段;二是获取指定日期从0点到24点的每个小时的时间段。通过Oracle SQL语句实现。
486

被折叠的 条评论
为什么被折叠?



