sqloracle-databaseoracle-sqldevelopersysdate

What does Oracle SYSDATE - 1/8 mean?


I am looking at a query:

select JOB_ID from db where last_updated_date >= sysdate - 1/8

I went through the ORACLE SYSDATE documentation but couldn't understand what sysdate - 1/8 means.

Please clarify.


Solution

  • In Oracle, it means you're subtracting 1/8 of the whole day. As one day has 24 hours, its 1/8th part is 24/8 = 3 hours. So:

    SQL> alter session set nls_date_format = 'dd.mm.yyyy hh24:mi:ss';
    
    Session altered.
    
    SQL> select sysdate col1,
      2         sysdate - 1/8 col2
      3  from dual;
    
    COL1                COL2
    ------------------- -------------------
    29.10.2021 22:18:36 29.10.2021 19:18:36
    
    SQL>
    

    It means that your query fetches rows whose last_updated_date column value is within the last 3 hours.