The Oracle SYSDATE
function returns the current date and time of the Operating System (OS) where the Oracle Database is running.
Syntax #
Since the SYSDATE
function does not require any argument, you can call it without specifying the parentheses:
SYSDATE
Code language: SQL (Structured Query Language) (sql)
Return value #
The SYSDATE
function returns the current date and time value whose type is DATE
.
The format of the returned date time value depends on the value of the NLS_DATE_FORMAT
parameter.
Examples #
The following example returns the current date and time of the OS where the Oracle Database resides:
SELECT
TO_CHAR(SYSDATE, 'MM-DD-YYYY HH24:MI:SS') result
FROM
dual;
Code language: SQL (Structured Query Language) (sql)
In this example, we used the TO_CHAR()
function to format the current system date and time value returned by the SYSDATE
function.
The following table illustrates the arithmetic of the SYSDATE
function:
SYSDATE Math | Description |
---|---|
WHERE (date) > SYSDATE - 8/24; | Past 8 hours |
WHERE (date) > SYSDATE - 30; | Past 30 days |
WHERE (date) > SYSDATE - | Past 30 minutes |
8/24 | 8 hours |
15/24/60/60 | 15 seconds |
1/24/60 | One minute |
1/24 | One hour |
TRUNC(SYSDATE+1/24,'HH') | 1 hour starting with the next hour |
Remarks #
The Oracle SYSDATE
function cannot be used in the condition of a CHECK
constraint.
Summary #
- Use the Oracle
SYSDATE
function to get the current system date and time.