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

前端 未结 5 1973
暗喜
暗喜 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:05

    Others have commented on the (incorrect) use of 2/11 to specify the desired interval.

    I personally however prefer writing things like that using ANSI interval literals which makes reading the query much easier:

    sysdate - interval '2' hour
    

    It also has the advantage of being portable, many DBMS support this. Plus I don't have to fire up a calculator to find out how many hours the expression means - I'm pretty bad with mental arithmetics ;)

提交回复
热议问题