Oracle SYS_EXTRACT_UTC() Function
Oracle SYS_EXTRACT_UTC()
is a built-in function that extracts the UTC from a datetime value with a time zone offset or time zone name.
Oracle SYS_EXTRACT_UTC()
Syntax
Here is the syntax for the Oracle SYS_EXTRACT_UTC()
function:
SYS_EXTRACT_UTC(datetime_with_timezone)
Parameters
datetime_with_timezone
-
Required. You should provide a datetime value with a time zone offset or time zone name. If there is no time zone, it will use the session time zone. You cannot provide a NULL value.
Return Value
The Oracle SYS_EXTRACT_UTC()
function returns a UTC value.
Oracle SYS_EXTRACT_UTC()
Examples
Here are some examples that demonstrate the usage of the Oracle SYS_EXTRACT_UTC()
function.
Basic Usage
ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SSXFF';
SELECT
SYS_EXTRACT_UTC(TIMESTAMP '2023-02-11 15:59:44.135000000 +05:00')
FROM dual;
Output:
SYS_EXTRACT_UTC(TIMESTAMP'2023-02-1115:59:44.135000000+05:00')
_________________________________________________________________
2023-02-11 10:59:44.135000000
NULL Parameter
You cannot provide a NULL parameter, otherwise SYS_EXTRACT_UTC()
will report an error.
SET NULL 'NULL';
SELECT
SYS_EXTRACT_UTC(NULL)
FROM dual;
Output:
SQL Error: ORA-30175: invalid type given for an argument
30175. 00000 - "invalid type given for an argument"
*Cause: There is an argument with an invalid type in the argument list.
*Action: Use the correct type wrapper for the argument.
Conclusion
Oracle SYS_EXTRACT_UTC()
is a built-in function that extracts the UTC from a datetime value with a time zone offset or time zone name.