Home > Oracle, SQL > Oracle – Select sysdate +/- time from dual

Oracle – Select sysdate +/- time from dual

If you want to find the sysdate less or plus a set amount of time (hours, minutes, seconds etc) you can issue the following:

Sysdate:

SQL> SELECT TO_CHAR(SYSDATE, 'dd-mm-yy hh24:mi:ss') from dual;

Days:

SQL> SELECT TO_CHAR(SYSDATE -1, 'dd-mm-yy hh24:mi:ss') from dual;

Hours:

SQL> SELECT TO_CHAR(SYSDATE-(1/24), 'dd-mm-yy hh24:mi:ss') from dual;

Minutes:

SQL> SELECT TO_CHAR(SYSDATE-1/(24*60), 'dd-mm-yy hh24:mi:ss') from dual;

Seconds:

SQL> SELECT TO_CHAR(SYSDATE-1/(24*60*60), 'dd-mm-yy hh24:mi:ss') from dual;

Likewise you can replace the – with a + to get the sysdate plus time i.e:

SQL> SELECT TO_CHAR(SYSDATE +1, 'dd-mm-yy hh24:mi:ss') from dual;

Advertisements
  1. Johnf0
    July 18, 2014 at 5:35 PM

    Valuable information. Fortunate me I discovered your web site by chance, and I am surprised why this coincidence didn’t happened in advance! I bookmarked it. befdefffebga

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: