如果您使用的是TIMESTAMP WITH TIME ZONE
數據類型:
甲骨文設置:
CREATE TABLE Table_Name (
open_time TIMESTAMP WITH TIME ZONE
);
INSERT INTO Table_Name VALUES (SYSTIMESTAMP AT TIME ZONE 'UTC');
查詢:
SELECT open_time AT TIME ZONE 'UTC' AS utc,
open_time AT TIME ZONE 'EST' AS est
FROM Table_Name;
輸出:
UTC EST
----------------------------------- -----------------------------------
02-MAR-16 22.41.38.344809000 UTC 02-MAR-16 17.41.38.344809000 EST
,或者如果你只是使用TIMESTAMP
數據類型:
甲骨文設置:
CREATE TABLE Table_Name (
open_time TIMESTAMP
);
INSERT INTO Table_Name VALUES (SYSTIMESTAMP);
查詢:
SELECT CAST(open_time AS TIMESTAMP WITH TIME ZONE) AT TIME ZONE 'UTC' AS utc,
CAST(open_time AS TIMESTAMP WITH TIME ZONE) AT TIME ZONE 'EST' AS est
FROM Table_Name;
輸出:
UTC EST
----------------------------------- -----------------------------------
02-MAR-16 22.41.38.344809000 UTC 02-MAR-16 17.41.38.344809000 EST
來源
2016-03-02 22:43:58
MT0
非常棒的答案,非常感謝您花時間簡潔地說明問題。 – Travis
注意時區'EST' **不**考慮夏令時,儘量'INSERT INTO TABLE_NAME VALUES(SYSTIMESTAMP +間隔 '6' 個月)AT TIME ZONE 'UTC');'作比較。使用區域名稱,例如'選擇OPEN_TIME AT TIME ZONE「美/東」從...'或'EST5EDT' –
我使用的這個,從我這個檢查是做我想要的。謝謝! 'select i.dtm_open_time ,FROM_TZ(cast(i.dtm_open_time as timestamp),'0:00')AT TIME ZONE'US/Eastern' from dcc.incident i' – Travis