PLSQL | CURRENT_TIMESTAMP Function

The PLSQL CURRENT_TIMESTAMP function is used to return the current date and time in session time zone. The time zone used is the time zone of the current SQL session as set by the ALTER SESSION command. The CURRENT_TIMESTAMP function returns a value of TIMESTAMP WITH TIME ZONE while the CURRENT_DATE function returns a value of DATE without time zone data.
The CURRENT_TIMESTAMP function accepts no parameters.

Syntax:

CURRENT_TIMESTAMP

Parameters Used:
The CURRENT_TIMESTAMP function accepts no parameters.

Return Value:
The CURRENT_TIMESTAMP function returns a value of the current timestamp in TIMESTAMP WITH TIME ZONE data type.

Supported Versions of Oracle/PLSQL:



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

Example-1: Using the CURRENT_TIMESTAMP function to show the current timestamp in the session time zone.

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

SELECT
  CURRENT_TIMESTAMP
FROM
  dual; 

Output:

Session altered.

CURRENT_TIMESTAMP
22-OCT-19 07.28.32.374935 AM +00:00 

Example-2: Using the CURRENT_TIMESTAMP function to show the current timestamp using altered session time zone.

ALTER SESSION SET TIME_ZONE = '-10:00';

SELECT
  CURRENT_TIMESTAMP
FROM
  dual; 

Output:

Session altered.

CURRENT_TIMESTAMP
21-OCT-19 09.31.40.273270 PM -10:00 

The new date and time was adjusted about -10 hours as expected.

Advantage:
The CURRENT_TIMESTAMP function returns a value of TIMESTAMP WITH TIME ZONE while the CURRENT_DATE function returns a value of DATE without time zone data.

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.