甲骨文获得1小时回溯日期 [英] Oracle get 1hr back date

查看:107
本文介绍了甲骨文获得1小时回溯日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Oracle中,我想获取特定的时间间隔.

In Oracle, I want to get specific intervals.

考虑,系统日期为2016年12月10日10:15:23(dd-mon-yyyy hh24:mi:ss).我想获得一个日期范围,如2016年12月10日09:00:00到2016年12月10日10:00:00

Consider, sysdate is 10-dec-2016 10:15:23 (dd-mon-yyyy hh24:mi:ss). I want to get a date period like 10-dec-2016 09:00:00 to 10-dec-2016 10:00:00

如何通过查询获取该日期段.如果您已观察到此日期段比当前HH24格式早1小时,并且四舍五入为00:00.该查询应适用于我设置的任何内容.上述日期为1小时.我应该可以设置2小时,3小时等任何时间.

How to get this date period through query. If you have observed this date period is 1hr back from current HH24 format and rounded to 00:00. The query should work for whatever I set. Above date period is for 1hr. I should be able to set for any number of hours like 2hrs,3hrs etc.

推荐答案

以下是示例

WITH dt AS
  ( SELECT ROUND(sysdate,'HH') hour_date FROM dual
  )
SELECT hour_date - 1/24, hour_date FROM dt

  1. 日期整整到最近的小时.
  2. 对于oracle日期算术,从DATE类型中减去1是24小时,因此1/24是一小时,依此类推.

这篇关于甲骨文获得1小时回溯日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆