ORACLE Casting DATE to TIMESTAMP WITH TIME ZONE WITH OFFSET

后端 未结 3 1346
臣服心动
臣服心动 2021-02-04 08:23

I need to cast a DATE value in a query to a TIMESTAMP WITH TIME ZONE, but currently I\'m getting the TimeZone Region (\'Europe / Paris\') which is not valid to be used by EF.

3条回答
  •  终归单人心
    2021-02-04 09:15

    With @Vincent Malgrat solution you need to get the TIMEZONE_HOUR and then, format it to use in your query. I don't know if there is any chance to make it automatically.

    I can suggest you to nest some functions. It is not the cleanest solution but it works for me

    SELECT TO_TIMESTAMP_TZ(TO_CHAR(CAST(FECHAHORA AS TIMESTAMP WITH TIME ZONE), 'DD-MM-YY HH24:MI:SS TZH:TZM'), 'DD-MM-YY HH24:MI:SS TZH:TZM' )FROM TEST;
    

    And the result will be something like

    03/03/14 09:58:02,000000000 +01:00
    

    Regards!

提交回复
热议问题