Some general notes:
SYSTIMESTAMP
and SYSDATE
are given in time zone of your database server's operating system. Thus changing database time zone (i.e. DBTIMEZONE
) does not change anything.
CAST (sys_extract_utc(systimestamp) AS TIMESTAMP)
, resp. cast(systimestamp at time zone 'UTC' as timestamp)
have a problem. You convert your timestamp to UTC but by CAST(... AS TIMESTAMP)
you remove any time zone information from that value. If you like to do any further conversion (e.g. again to TIMESTAMP WITH TIME ZONE
value) then your input UTC value is considered to be a SESSIONTIMEZONE
value.
from_tz(CAST (sys_extract_utc(systimestamp) AS TIMESTAMP), '+00:00')
does following:
- Get current time in time zone of your database server's operating system, include time zone information.
- Convert this time to UTC, cut time zone information
- Append time zone information (
+00:00
) to this value
Correct output but redundant conversion
cast(sysdate as timestamp) at time zone 'UTC'
does following:
- Get current time in time zone of your database server's operating system, without any time zone information.
- Cast to TIMESTAMP (basically no effect at all)
- Consider this value as time in your local session time zone (
SESSIONTIMEZONE
) and convert to UTC.
Correct output only if time zone of your database server's operating system is the same as your local session time zone, otherwise you get wrong result.
from_tz(cast(systimestamp at time zone 'UTC' as timestamp), '+0:00')
does following:
- Get current time in time zone of your database server's operating system, include time zone information.
- Convert this time to UTC
- Cut time zone information
- Append time zone information (
+00:00
) to this value
Correct output but redundant conversion
from_tz(cast(systimestamp as timestamp), '+0:00')
does following:
- Get current time in time zone of your database server's operating system, include time zone information.
- Cut time zone information
- Append time zone information (
+00:00
) to this value
Correct output only if time zone of your database server's operating system is UTC.