For some reason, it is not possible to convert TIMESTAMP WITH TIMEZONE correctly from one time zone to another, for example:
SELECT SYSTIMESTAMP, DBTIMEZONE, CURRENT_TIMESTAMP SESSIONTIMEZONE FROM DUAL; ============================================================================================================================================================================================================= | SYSTIMESTAMP | DBTIMEZONE | CURRENT_TIMESTAMP | SESSIONTIMEZONE | ============================================================================================================================================================================================================= | 20.07.2017 7:15:33 -04:00 | Europe/Moscow | 20.07.2017 14:15:33 +03:00 | +03:00 | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Second example:
SELECT SYSTIMESTAMP, SYSTIMESTAMP AT TIME ZONE 'Europe/Moscow' Moscow, SYSTIMESTAMP AT TIME ZONE 'America/New_York' New_York FROM DUAL ========================================================================================================================================================== | SYSTIMESTAMP | MOSCOW | NEW_YORK | ========================================================================================================================================================== | 20.07.2017 7:09:25 -04:00 | 20.07.2017 11:09:25 +00:00 | 20.07.2017 11:09:25 +00:00 | ---------------------------------------------------------------------------------------------------------------------------------------------------------- In this case, as a result of the conversion, the time zone was completely reset, despite the successful execution of the conversion.
- Why in the first example the result of
CURRENT_TIMESTAMPis one hour behind the real one, which should be15:15:33, not14:15:33? - Why in the second example, despite the successful execution of the command, the conversion does not occur? Maybe some database parameters are not configured, or I do not understand how
AT TIME ZONEworks? I took the names of the time zones fromV$TIMEZONE_NAMES.
Database Version: Oracle Database 12c Standard Edition Release 12.2.0.1.0 - 64bit Production
UPD: Data from nls_session_parameters
SQL Developer
NLS_LANGUAGE RUSSIAN NLS_TERRITORY RUSSIA NLS_CURRENCY â‚˝ NLS_ISO_CURRENCY RUSSIA NLS_NUMERIC_CHARACTERS , NLS_CALENDAR GREGORIAN NLS_DATE_FORMAT DD.MM.RR NLS_DATE_LANGUAGE RUSSIAN NLS_SORT RUSSIAN NLS_TIME_FORMAT HH24:MI:SSXFF NLS_TIMESTAMP_FORMAT DD.MM.RR HH24:MI:SSXFF NLS_TIME_TZ_FORMAT HH24:MI:SSXFF TZR NLS_TIMESTAMP_TZ_FORMAT DD.MM.RR HH24:MI:SSXFF TZR NLS_DUAL_CURRENCY â‚˝ NLS_COMP BINARY NLS_LENGTH_SEMANTICS BYTE NLS_NCHAR_CONV_EXCP FALSE dbForge
NLS_LANGUAGE AMERICAN NLS_TERRITORY AMERICA NLS_CURRENCY $ NLS_ISO_CURRENCY AMERICA NLS_NUMERIC_CHARACTERS ., NLS_CALENDAR GREGORIAN NLS_DATE_FORMAT DD-MON-RR NLS_DATE_LANGUAGE AMERICAN NLS_SORT BINARY NLS_TIME_FORMAT HH.MI.SSXFF AM NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR NLS_DUAL_CURRENCY $ NLS_COMP BINARY NLS_LENGTH_SEMANTICS CHAR NLS_NCHAR_CONV_EXCP FALSE