I've worked with Oracle's timestamp with time zone before, but this time I'm getting values as strings and trying to load them to the database.
When converting the string, I end up with a value in the database time zone. This is odd, but workable if it adjusted the time accordingly yet it doesn't. See below:
SELECT TO_CHAR(systimestamp AT TIME ZONE 'Canada/Pacific',
'HH24:MI:SS Mon DD, YYYY TZD') now_pst
, TO_CHAR(systimestamp AT TIME ZONE 'Canada/Eastern',
'HH24:MI:SS Mon DD, YYYY TZD') now_est
FROM DUAL
which results in:
now_pst now_est
09:55:50 Dec 19, 2016 PST 12:55:50 Dec 19, 2016 EST
now to use to_timestamp_tz:
SELECT '09:55:50 Dec 19, 2016 PST' now_pst
, TO_TIMESTAMP_TZ('09:55:50 Dec 19, 2016 PST', 'HH24:MI:SS Mon DD, YYYY TZD') now_pst_tz
, '12:55:50 Dec 19, 2016 EST' now_est
, TO_TIMESTAMP_TZ('12:55:50 Dec 19, 2016 EST', 'HH24:MI:SS Mon DD, YYYY TZD') now_est_tz
FROM dual
the result:
now_pst now_pst_tz now_est now_est_tz
09:55:50 Dec 19, 2016 PST 19.12.2016 09:55:50.000 -05:00 12:55:50 Dec 19, 2016 EST 19.12.2016 12:55:50.000 -05:00
what I should get is: NOW_PST_TZ = 19.12.2016 09:55:50.000 -08:00 (not -05:00)
NOW_EST_TZ = 19.12.2016 12:55:50.000 -05:00
I have a lot of expectations that aren't happening here, but mainly that these are supposed to be the same time - one in Canada/Eastern and one in Canada/Pacific. Yet I'm getting 2 different times.
to_timestamp_tz is failing to convert the string to the correct TZD.
as requested:
select sessiontimezone, dbtimezone from dual
result:
SESSIONTIMEZONE DBTIMEZONE
-05:00 +00:00