码迷,mamicode.com
首页 > 数据库 > 详细

oracle 获取时间

时间:2019-01-28 18:24:30      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:bsp   image   dual   sel   span   select   nec   分享   color   

1、获取当前时间的前24小时的各小时时间段

select
    to_char(to_date(to_char(sysdate - (rownum - 1) / 24,‘yyyy-mm-dd hh24‘)
                        || ‘:00:00‘,‘yyyy-mm-dd hh24:mi:ss‘),‘yyyy-mm-dd hh24:mi:ss‘) totaldate
from
    dual
connect by
    rownum <= 24
order by
    totaldate desc

 技术分享图片

 

2、获取某天的0点到24点的各小时时间段

select
    TO_CHAR(to_date(‘2019-01-28‘,‘yyyy-mm-dd‘) + (rownum - 1) / 24,‘yyyy-mm-dd hh24:mi:ss‘) TIMES
from
    DUAL
connect by
    level <= 24

 技术分享图片

 

oracle 获取时间

标签:bsp   image   dual   sel   span   select   nec   分享   color   

原文地址:https://www.cnblogs.com/dqcer/p/10331231.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!