CURRENT_TIMESTAMP

2024-06-28 05:30:31  Updated

Purpose

CURRENT_TIMESTAMP() returns the current date in the time zone of the current session. The return value contains the time zone information.

Syntax

CURRENT_TIMESTAMP[(precision)]

Parameters

precision specifies the fractional seconds precision. It is an integer in the range of [0, 9]. This parameter is optional. Its default value is 6.

Return type

The return type is TIMESTAMP WITH TIME ZONE.

Examples

  • The following example sets the time zone of the current session to GMT-5 and returns the time and time zone of the session with two decimal places for fractional seconds.

    obclient> ALTER SESSION SET TIME_ZONE = '-05:00';
    Query OK, 0 rows affected
    
    obclient> SELECT CURRENT_TIMESTAMP(2) FROM DUAL;
    +---------------------------------+
    | CURRENT_TIMESTAMP(2)            |
    +---------------------------------+
    | 17-NOV-21 04.22.51.13 AM -05:00 |
    +---------------------------------+
    1 row in set
    
  • The following example sets the time zone of the current session to GMT+8 and returns the time and time zone of the session with two decimal places for fractional seconds.

    obclient> ALTER SESSION SET TIME_ZONE = '+08:00';
    Query OK, 0 rows affected
    
    obclient> SELECT CURRENT_TIMESTAMP(2) FROM DUAL;
    +---------------------------------+
    | CURRENT_TIMESTAMP(2)            |
    +---------------------------------+
    | 17-NOV-21 05.23.01.92 PM +08:00 |
    +---------------------------------+
    1 row in set
    

Contact Us