Oracle Date/Time Function - Oracle/PLSQL CURRENT_TIMESTAMP Function






This Oracle tutorial explains how to use the Oracle/PLSQL CURRENT_TIMESTAMP function.

CURRENT_TIMESTAMP returns a TIMESTAMP WITH TIME ZONE for the session.

The session can be set by the ALTER SESSION command. It returns a TIMESTAMP WITH TIME ZONE value.

There is a LOCALTIMESTAMP function in Oracle. CURRENT_TIMESTAMP function returns a TIMESTAMP WITH TIME ZONE value while the LOCALTIMESTAMP function returns a TIMESTAMP value.

Syntax

The syntax for the Oracle/PLSQL CURRENT_TIMESTAMP function is:

CURRENT_TIMESTAMP

There are no parameters for the CURRENT_TIMESTAMP function.

Example


SQL> SELECT CURRENT_TIMESTAMP FROM dual;
-- from ww  w  .j  av a 2s.  c  o  m
CURRENT_TIMESTAMP
--------------------------------------------------------
08-JUL-12 10.17.33.899000 AM -07:00

SQL>
SQL> ALTER SESSION SET TIME_ZONE = 'EST';

Session altered.

SQL>
SQL> SELECT CURRENT_TIMESTAMP FROM dual;

CURRENT_TIMESTAMP
--------------------------------------------------------
08-JUL-12 01.17.34.040000 PM EST

SQL>
SQL> ALTER SESSION SET TIME_ZONE = 'PST';

Session altered.

SQL>
SQL>
SQL> SELECT CURRENT_TIMESTAMP FROM dual;

CURRENT_TIMESTAMP
--------------------------------------------------------
08-JUL-12 10.17.34.837000 AM PST

SQL>