2017-03-09 60 views
1

oracle數據庫存儲日期偏移列,該列用於將UTC日期轉換爲CST。然後當你選擇你會這樣做:Hive - 將日期從UTC手動轉換爲CSRT

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

我們正在努力實現這一實施HIVE SQL。

+0

請添加包括所需的結果 –

回答

0
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  | 
+----------------------+---------------+-------------------------+ 
+0

羅傑先生是一個小的數據樣本!我需要的唯一的調整就是將CAST轉換爲INT上的偏移量,因爲它被定義爲DECIMAL。 – JB11

+0

偉大的:-)。請不要忘記接受答案 –