手动将日期从utc转换为csrt

yzuktlbb  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(339)

oracle数据库存储一个日期偏移列,用于将utc日期转换为cst。当您选择时,您将执行以下操作:

select ConnectedDatetimeUTC,
CAST(connecteddatetimeutc + (startdtoffset/ (24 * 60 * 60)) as timestamp(3)) as connecteddattimeManual2
from table1

我们正努力在配置单元sql中实现这一点。

j2cgzkjk

j2cgzkjk1#

with    table1 as 
        (
            select  timestamp '2017-02-28 23:58:41' as connecteddatetimeutc
                   ,1234                            as startdtoffset
        )

select  ConnectedDatetimeUTC
       ,startdtoffset
       ,from_unixtime (unix_timestamp(connecteddatetimeutc) + startdtoffset) as connecteddattimeManual2

from    table1
;
+----------------------+---------------+-------------------------+
| connecteddatetimeutc | startdtoffset | connecteddattimemanual2 |
+----------------------+---------------+-------------------------+
| 2017-02-28 23:58:41  |          1234 | 2017-03-01 00:19:15     |
+----------------------+---------------+-------------------------+

相关问题