Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Alter session timezone and TIMESTAMP WITH LOCAL TIME ZONE

RNMay 18 2020 — edited May 18 2020

Hello all,

I understand that there is tons of info available on this topic but I couldn't get an answer specific to my question. I might have a wrong understanding on this topic, and hence my question.

--using Oracle 18c

SELECT SYSTIMESTAMP FROM DUAL;

--18-MAY-20 04.07.45.330583000 PM -04:00

SELECT DBTIMEZONE FROM DUAL;

--+00:00

SELECT SESSIONTIMEZONE FROM DUAL;

--America/New_York

DROP TABLE TEST_T;

CREATE TABLE TEST_T

(RECORD_ID NUMBER, DATE_CREATED TIMESTAMP WITH LOCAL TIME ZONE);

ALTER SESSION SET TIME_ZONE = '-07:00';

SELECT SESSIONTIMEZONE FROM DUAL;

-- -07:00

INSERT INTO TEST_T VALUES (1, TIMESTAMP '2009-09-03 00:00:00.000000 PST');

SELECT * FROM TEST_T;

--1 03-SEP-09 03.00.00.000000000 AMĀ  --why it it giving me 3am.. shouldn't it return midnight because my session timezone is same as what I have in insert statement

ALTER SESSION SET TIME_ZONE = '-04:00';

SELECT SESSIONTIMEZONE FROM DUAL;

-- -04:00

SELECT * FROM TEST_T;

--03-SEP-09 03.00.00.000000000 AM -- alter session timezone made no difference.. why?

Thanks,

RN

This post has been answered by mathguy on May 18 2020
Jump to Answer
Comments
Post Details
Added on May 18 2020
3 comments
2,664 views