在UTC ODBC连接中将UTC日期/时间戳转换为本地时区

时间:2014-07-10 16:02:55

标签: sql excel oracle vba odbc

我有一个通过ODBC连接到Oracle数据库的Excel。我从数据库中获取UTC时间戳,我想将此时间戳转换为CET。

死有人知道吗?

样品:

SELECT
    V_CHANGE_SELECTED_DATA.INFRASTRUCTURE_CHANGE_ID INFRASTRUCTURE_CHANGE_ID,
    V_CHANGE_SELECTED_DATA.ITSM_SERVICE_NAME,
    V_CHANGE_SELECTED_DATA.IMPACTED_SITE_GROUP,
    V_CHANGE_SELECTED_DATA.SUMMARY,
    V_CHANGE_SELECTED_DATA.NOTES,
    V_CHANGE_SELECTED_DATA.IMPACT,
    V_CHANGE_SELECTED_DATA.STATUS,
    V_CHANGE_SELECTED_DATA.SCHEDULED_START_DATE, -- UTC
    V_CHANGE_SELECTED_DATA.SCHEDULED_END_DATE -- UTC
FROM QQITSMREP_READ.V_CHANGE_SELECTED_DATA V_CHANGE_SELECTED_DATA
WHERE V_CHANGE_SELECTED_DATA.SCHEDULED_START_DATE >= to_date (SYSDATE)
    AND V_CHANGE_SELECTED_DATA.IMPACTED_SITE_GROUP like ? -- Parameter

任何帮助将不胜感激。

此致 夸斯特

1 个答案:

答案 0 :(得分:0)

试试这个:

(V_CHANGE_SELECTED_DATA.SCHEDULED_START_DATE at time zone sessiontimezone) AS SCHEDULED_START_DATEAS 
or
(V_CHANGE_SELECTED_DATA.SCHEDULED_START_DATE at local) AS SCHEDULED_START_DATEAS 

也许ODBC不支持timestamp数据类型。尝试将其转换为DATE类型:

CAST((V_CHANGE_SELECTED_DATA.SCHEDULED_START_DATE at local) AS DATE) AS SCHEDULED_START_DATEAS