Oracle / PLSQL: CURRENT_TIMESTAMP function

This article is written about how to use the Oracle/PLSQL CURRENT_TIMESTAMP function with syntax and examples.

Description

The Oracle/PLSQL CURRENT_TIMESTAMP function returns the current date and time in the time zone of the current SQL session as set by the ALTER SESSION command. It returns a TIMESTAMP WITH TIME ZONE value.

Syntax

The syntax for the CURRENT_TIMESTAMP function in Oracle/PLSQL is:

CURRENT_TIMESTAMP

Parameters or Arguments

There are no parameters or arguments for the CURRENT_TIMESTAMP function.

Returns

The CURRENT_TIMESTAMP function returns a TIMESTAMP WITH TIME ZONE value.

Note

A similar function to the CURRENT_TIMESTAMP function is the LOCALTIMESTAMP function.

The difference between these two functions is that the CURRENT_TIMESTAMP function returns a TIMESTAMP WITH TIME ZONE value while the LOCALTIMESTAMP function returns a TIMESTAMP value.

Applies To

The CURRENT_TIMESTAMP function can be used in the following versions of Oracle/PLSQL:

Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i

Example

The CURRENT_TIMESTAMP function can be used in Oracle/PLSQL.

If the following ALTER SESSION command was issued:

ALTER SESSION SET TIME_ZONE = '-7:0';

And then the following SQL statement was executed:

select CURRENT_TIMESTAMP
from dual;

You might get the following result:

10-Sep-05 10.58.24.853421 PM -07:00

You then modified the session time zone with the following ALTER SESSION command:

ALTER SESSION SET TIME_ZONE = '-2:0';

And then the following SQL statement was executed:

select CURRENT_TIMESTAMP
from dual;

You would now get the following result:

10-Sep-05 03.58.24.853421 AM -02:00

The session time zone value has changed from -7:0 to -2:0, causing the CURRENT_TIMESTAMP function to return the current date and time as a value 5 hours ahead.