Oracle SYSDATE Function
Oracle SYSDATE
is a built-in function that returns the current date and time as set in the operating system of the database server.
Oracle SYSDATE
Syntax
Here is the syntax for the Oracle SYSDATE
function:
SYSDATE
Note that you cannot use parentheses after the function name.
Parameters
The Oracle SYSDATE
function does not require any parameters.
Return Value
The Oracle SYSDATE
function returns the current date and time as set in the operating system of the database server.
Oracle SYSDATE
Examples
Here are some examples of how to use the Oracle SYSDATE
function.
Basic Usage
To get the current date, use the following statement:
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD';
SELECT
SYSDATE
FROM dual;
Output:
SYSDATE
_______________
2023-02-11
Here, we use the ALTER SESSION
statement to modify the date display format for the current session to YYYY-MM-DD
.
Current Time
You can explicitly display the current date and time by modifying the date format for the current session.
First, modify the date display format for the current session to YYYY-MM-DD HH24:MI:SS
:
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS';
Then, execute the SYSDATE
function:
SELECT
SYSDATE
FROM dual;
Output:
SYSDATE
______________________
2023-02-11 14:41:47
Conclusion
Oracle SYSDATE
is a built-in function that returns the current date and time as set in the operating system of the database server.