In Oracle Database, the CURRENT_DATE
function returns the current date in the session time zone, in a value in the Gregorian calendar of data type DATE
.
Syntax
The syntax goes like this:
CURRENT_DATE
So, no arguments are required (or accepted), and there are no parentheses.
Example
Here’s an example:
SELECT CURRENT_DATE
FROM DUAL;
Result:
06/AUG/21
This example displays the date based on the value of my system’s NLS_DATE_FORMAT
parameter (which is currently DD/MON/RR
). We can either change this parameter, or use a function like TO_CHAR()
to return the result in a different format.
Example:
SELECT TO_CHAR(CURRENT_DATE, 'YYYY-MM-DD')
FROM DUAL;
Result:
2021-08-06
Calling CURRENT_DATE
with Parentheses
As mentioned, the CURRENT_DATE
function is called without parentheses.
Here’s what happens when we call it with parentheses:
SELECT CURRENT_DATE()
FROM DUAL;
Result:
Error starting at line : 1 in command - SELECT CURRENT_DATE() FROM DUAL Error at Command Line : 1 Column : 20 Error report - SQL Error: ORA-00923: FROM keyword not found where expected 00923. 00000 - "FROM keyword not found where expected" *Cause: *Action: