first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

PL/SQL: Oracle 7; Date Arithmetic with SYSDATE

SYSDATE stores dates in days by default. It follows that all arithmetic operations with SYSDATE as an operand must be units of days. For example, to subtract 30 minutes from the current time, convert 30 minutes into units of days:

30 [minutes]/1440 [minutes/day] = 0.02083

In SQL*Plus we have:

SELECT TO_CHAR(SYSDATE - 0.02083, 'HH:MI:SS') OUT
FROM DUAL;

Where OUT is just an arbitrary column name for readability.

To verify that SYSDATE is, by default, in units of days, run the following to get yesterday's date:

SELECT TO_CHAR(SYSDATE - 1, 'MM/DD/YY') OUT
FROM DUAL;
mod date: 2000-12-24T22:51:51.000Z