Oracle CURRENT_TIMESTAMP() Function

Oracle CURRENT_TIMESTAMP() is a built-in function that returns the current date and time in the current session time zone, as a value of the TIMESTAMP WITH TIME ZONE data type.

Oracle CURRENT_TIMESTAMP() Syntax

Here is the syntax for the Oracle CURRENT_TIMESTAMP() function:

CURRENT_TIMESTAMP

or

CURRENT_TIMESTAMP(precision)

Parameters

precision

Optional. Specifies the precision of the fractional seconds value in the returned time value. It must be a number between 0 and 9. You cannot pass a NULL value, or Oracle will give an error.

Return Value

The Oracle CURRENT_TIMESTAMP() function returns the current date and time value in the current session time zone as a TIMESTAMP WITH TIME ZONE data type value.

Oracle CURRENT_TIMESTAMP() Examples

Here are a few examples demonstrating the usage of the Oracle CURRENT_TIMESTAMP() function.

Basic Usage

To retrieve the current date and time, use the following statement:

ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT = 'YYYY-MM-DD HH24:MI:SSXFF TZR';
SELECT
    CURRENT_TIMESTAMP
FROM dual;

Output:

CURRENT_TIMESTAMP
______________________________________________
2023-02-11 14:19:35.238000000 ASIA/SHANGHAI

Here, we use the ALTER SESSION statement to modify the date display format for the current session.

Fractional Seconds

The Oracle CURRENT_TIMESTAMP() function allows you to specify the precision of the fractional seconds:

SELECT
    CURRENT_TIMESTAMP(1)
FROM dual;

Output:

CURRENT_TIMESTAMP(1)
______________________________________________
2023-02-11 14:20:47.800000000 ASIA/SHANGHAI

Conclusion

Oracle CURRENT_TIMESTAMP() is a built-in function that returns the current date and time in the current session time zone, as a value of the TIMESTAMP WITH TIME ZONE data type.