How to subtract hours from a date in Oracle so it affects the day also

前端 未结 5 1975
暗喜
暗喜 2021-02-01 17:23

I\'m trying to subtract date from Oracle so it even effect the day as well. For example, if the timestamp is 01/June/2015 00 hours and if I subtract 2 hours, I want to be able

5条回答
  •  广开言路
    2021-02-01 18:03

    date - n will subtract n days form given date. In order to subtract hrs you need to convert it into day buy dividing it with 24. In your case it should be to_char(sysdate - (2 + 2/24), 'MM-DD-YYYY HH24'). This will subract 2 days and 2 hrs from sysdate.

提交回复
热议问题