w3resource

Oracle CURRENT_DATE function

How to get the current date in the session time zone in Oracle?

CURRENT_DATE returns the current date in the session time zone, in a value in the Gregorian calendar of datatype DATE.

Syntax:

CURRENT_DATE

Parameters:
No parameters or arguments

Applies to:
Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i

Pictorial Presentation

Pictorial Presentation of Oracle CURRENT_DATE function

Example: Oracle CURRENT_DATE() function

The following statement shows the current date in 'DD-MON-YYYY HH24:MI:SS' format :

SQL> ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
Session altered.

Let display the current date and session timezone.:

SQL> ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
Session altered.
SQL> SELECT CURRENT_DATE, SESSIONTIMEZONE FROM DUAL;

Sample Output:

CURRENT_DATE            SESSIONTIMEZONE
--------------------    -----------------------
01-MAY-2015 11:19:41    +05:30

Let change the session timezone using ALTER SESSION command :

SQL> ALTER SESSION SET TIME_ZONE = '-2:0';
Session altered.

Now check the current date and session timezone :

SQL> SELECT CURRENT_DATE, SESSIONTIMEZONE FROM DUAL;

Sample Output:

CURRENT_DATE            SESSIONTIMEZONE
--------------------    -----------------------
01-MAY-2015 04:26:26    -02:00

Previous: ADD_MONTHS
Next: CURRENT_TIMESTAMP



Share this Tutorial / Exercise on : Facebook and Twitter