PLSQL | CURRENT_DATE Function

The PLSQL CURRENT_DATE function is used to return the current date in the session time zone. The time zone used is the time zone of the current SQL session as set by the ALTER SESSION command. The PLSQL CURRENT_DATE function uses its value from the Gregorian calendar of datatype DATE.
The CURRENT_DATE function accepts no parameters.

Syntax:

CURRENT_DATE

Parameters Used:
The CURRENT_DATE function accepts no parameters.

Return Value:
The CURRENT_DATE function returns a date value.

Supported Versions of Oracle/PLSQL:



  1. Oracle 12c
  2. Oracle 11g
  3. Oracle 10g
  4. Oracle 9i
  5. Oracle 8i

Example-1: Using the SESSIONTIMEZONE function to find the session time zone.

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';

SELECT
  SESSIONTIMEZONE
FROM
  DUAL; 

Output:

Session altered.

SESSIONTIMEZONE
+00:00 

Example-2: Using the CURRENT_DATE function to get the current date in the session time zone.

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';

SELECT
  SESSIONTIMEZONE
FROM
  DUAL;
  
SELECT
  CURRENT_DATE
FROM
  DUAL; 

Output:

Session altered.

SESSIONTIMEZONE
+00:00

CURRENT_DATE
22-OCT-2019 06:53:58 

Example-3: Using the CURRENT_DATE function after altering the session time zone to get the current date.

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';

SELECT
  SESSIONTIMEZONE
FROM
  DUAL;
 
ALTER SESSION SET TIME_ZONE = '-02:00';
  
SELECT
  CURRENT_DATE
FROM
  DUAL; 

Output:

Session altered.

SESSIONTIMEZONE
+00:00

Session altered.

CURRENT_DATE
22-OCT-2019 05:05:36 

The new current date was adjusted about -2 hours as expected.

My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.