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!

how to find time difference between time zones ?

Sa SiApr 1 2019 — edited Apr 9 2019

create table test_tz(

col1 varchar2(10),

col2 timestamp);

insert into test_tz select dbms_random.string('A','10'), systimestamp at time zone 'Europe/London' from dual;

select * from test_tz;

COL1COL2
OlvUrITHKp01-APR-19 05.59.57.644499 PM
PyHHhJvHrG01-APR-19 06.00.02.327258 PM
cSoHaaEyzr01-APR-19 05.59.51.722169 PM
msIjcgAGbM01-APR-19 05.59.53.411279 PM

when i try to find difference of time like this

select systimestamp at time zone dbtimezone tz , col2, systimestamp at time zone dbtimezone - col2 diff from test_tz;

i am getting time difference of 7 hours. as you can see below in the column DIFF which is wrong, now i tried to extract hour, day and minutes also, even that did not work.

TZCOL2DIFF
01-APR-19 05.03.11.654567 PM +00:0001-APR-19 05.59.57.644499 PM-000000000 07:56:45.989932
01-APR-19 05.03.11.654567 PM +00:0001-APR-19 06.00.02.327258 PM-000000000 07:56:50.672691
01-APR-19 05.03.11.654567 PM +00:0001-APR-19 05.59.51.722169 PM-000000000 07:56:40.067602
01-APR-19 05.03.11.654567 PM +00:0001-APR-19 05.59.53.411279 PM-000000000 07:56:41.756712

how can i find the time difference between 2 different time zones, can anyone please help ?

This post has been answered by Gaz in Oz on Apr 2 2019
Jump to Answer
Comments
Post Details
Added on Apr 1 2019
19 comments
6,655 views