甲骨文。与时区的时间戳中的正确偏移量

时间:2015-08-20 08:35:19

标签: sql oracle oracle11g timestamp-with-timezone

我现在正在执行此选择

SELECT FROM_TZ(to_timestamp('2015-08-08 10:00:00', 'yyyy-mm-dd hh24:mi:ss'),'Asia/Singapore') AT TIME ZONE 'UTC'
FROM DUAL

我对time感兴趣,在这种情况下,时间为02:00 AM,因为Singapore UTC中的8 hours之间存在差异。08更改为01,我希望得到03:00 AM,因为这是冬天的时间{ {1}},但我再次凌晨02:00。所以问题是,我怎样才能得到正确偏移的正确结果?

1 个答案:

答案 0 :(得分:1)

Asia/Singapore没有任何夏令时,请参见此处:Singapore Standard Time

Crazy,Oracle正确实施了这个列表:

SELECT FROM_TZ(TO_TIMESTAMP('2015-01-08 10:00:00', 'yyyy-mm-dd hh24:mi:ss'), 'Asia/Singapore') AS TS FROM DUAL;
TS                                      
----------------------------------------
08.01.2015 10:00:00.000000000 +08:00    
1 row selected.

SELECT FROM_TZ(TO_TIMESTAMP('1970-01-08 10:00:00', 'yyyy-mm-dd hh24:mi:ss'), 'Asia/Singapore') AS TS FROM DUAL;
TS                                      
----------------------------------------
08.01.1970 10:00:00.000000000 +07:30    
1 row selected.

SELECT FROM_TZ(TO_TIMESTAMP('1943-01-08 10:00:00', 'yyyy-mm-dd hh24:mi:ss'), 'Asia/Singapore') AS TS FROM DUAL;
TS                                      
----------------------------------------
08.01.1943 10:00:00.000000000 +09:00    
1 row selected.

SELECT FROM_TZ(TO_TIMESTAMP('1940-01-08 10:00:00', 'yyyy-mm-dd hh24:mi:ss'), 'Asia/Singapore') AS TS FROM DUAL;
TS                                      
----------------------------------------
08.01.1940 10:00:00.000000000 +07:20    
1 row selected.

SELECT FROM_TZ(TO_TIMESTAMP('1920-01-08 10:00:00', 'yyyy-mm-dd hh24:mi:ss'), 'Asia/Singapore') AS TS FROM DUAL;
TS                                      
----------------------------------------
08.01.1920 10:00:00.000000000 +07:00    
1 row selected.