Oracle SYSDATE Function
The Oracle (PL/SQL) SYSDATE function returns the current date and time set for the operating system on which the database resides. The datatype of the returned value is DATE, and the format returned depends on the value of the NLS_DATE_FORMAT initialization parameter. The function requires no arguments. In distributed SQL statements, this function returns the date and time set for the operating system of the local database.
Syntax
SYSDATE
Parameters
No parameter is required.
Return Value
Returns the current date and time set for the operating system on which the database resides.
Example 1:
The example below shows the usage of SYSDATE function.
SYSDATE Result: '27-DEC-2021 05:11:57'
Example 2:
The example below illustrates how to use the NLS_DATE_FORMAT to change the format of the result:
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24.MI.SS'; SELECT SYSDATE FROM DUAL; Result: SYSDATE -------------------- 29-MAY-2000 13.14.03 ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS'; SELECT SYSDATE FROM DUAL; Result: SYSDATE -------------------- 29-MAY-2000 13:14:03
Example 3:
Consider a database table called Employee with the following records:
EmpID | Name | Age | Date_of_Joining |
---|---|---|---|
1 | John | 25 | 25-MAY-2018 09:20:38 |
2 | Marry | 24 | 15-OCT-2018 09:21:05 |
3 | Jo | 27 | 09-JUN-2019 09:24:35 |
4 | Kim | 30 | 21-SEP-2019 09:25:24 |
5 | Ramesh | 28 | 25-OCT-2019 09:27:16 |
To insert a new record in this table, the following statement can be used.
INSERT INTO Employee VALUES (6, 'Suresh', 28, SYSDATE); -- see the result SELECT * FROM Employee;
This will produce a result similar to:
EmpID | Name | Age | Date_of_Joining |
---|---|---|---|
1 | John | 25 | 25-MAY-2018 09:20:38 |
2 | Marry | 24 | 15-OCT-2018 09:21:05 |
3 | Jo | 27 | 09-JUN-2019 09:24:35 |
4 | Kim | 30 | 21-SEP-2019 09:25:24 |
5 | Ramesh | 28 | 25-OCT-2019 09:27:16 |
6 | Suresh | 28 | 26-DEC-2021 09:28:19 |
❮ Oracle Functions