Search code examples
oracledatetimeplsqldate-arithmetic

Subtract one hour from datetime rather than one day


I have a datetime column in Oracle (MM/DD/YYYY HH:MM:SS AM/PM) but when I do this:

SELECT MAX(D_DTM)-1 FROM tbl1

...it goes back a day. How do I remove one hour from the column rather than one day?

I've also noticed that the datetime records for 12AM look like MM/DD/YYYY and not MM/DD/YYYY 00:00:00; I'm not sure if that matters.


Solution

  • Randy's answer is good, but you can also use intervals:

    SELECT MAX(D_DTM)- interval '1' hour FROM tbl1