Oracle CURRENT_DATE

The Oracle CURRENT_DATE function returns the current date in the session time zone.

Syntax

The Oracle CURRENT_DATE function requires no argument and its syntax is as simple as follows:

CURRENT_DATE
Code language: SQL (Structured Query Language) (sql)

Return value

The Oracle CURRENT_DATE function returns a DATE value in the Gregorian calendar.

Examples

The following statement changes the default date format to a new one that includes the time data:

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
Code language: SQL (Structured Query Language) (sql)

To find out the session time zone, you use the SESSIONTIMEZONE function as follows:

SELECT
  SESSIONTIMEZONE
FROM
  DUAL;Code language: SQL (Structured Query Language) (sql)

Currently, the session time zone is set to -07:00.

To get the current date in the session time zone, you use the following statement:

SELECT
  CURRENT_DATE
FROM
  DUAL;
Code language: SQL (Structured Query Language) (sql)

Here is the output:

06-AUG-2017 19:43:44Code language: SQL (Structured Query Language) (sql)

If you change the session time zone, the value of the current date is adjusted accordingly as shown in the following example:

First, set the session time zone to -09:00:

ALTER SESSION SET TIME_ZONE = '-09:00';
Code language: SQL (Structured Query Language) (sql)

Second, get the current date in the session time zone:

06-AUG-2017 17:45:33
Code language: SQL (Structured Query Language) (sql)

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

In this tutorial, you have learned how to use the Oracle  CURRENT_DATE function to get the current date and time in the session time zone.

Was this tutorial helpful?