Search code examples
sqloracletimesysdate

Round up SYSDATE just but its HOUR. SQL ORACLE


Any ideas how to round up SYSDATE.

For example, sysdate right now is 11.31, and i want it to round up to 12.00, but i expect the output to be just 12, and if the Sysdate is 11.29, the output is 11.

Thanks


Solution

  • ROUND((SYSDATE-TRUNC(SYSDATE))*24)
    

    Explanation: TRUNC without 2nd parameter makes the 00:00:00 time of the current date. By subtraction we get the difference (in days), then scale it to hours and round.