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.

Uses of Oracle CURRENT_DATE Function
  • Retrieve Current Date: Get the current date based on the session time zone.

  • Time Zone Awareness: Display the current date and time according to the session's time zone.

  • Date Formatting: Use with NLS_DATE_FORMAT to display the current date in various formats.

  • Session Customization: Adapt the current date output by altering the session time zone.

  • Date Tracking: Keep track of events or transactions based on the current session's 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



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/oracle/datetime-functions/oracle-current_date-function.php