我已經在hadoop上安裝了hive 2.1.1,其中我使用列(dis string,dt timestamp)創建了名稱數據表。我想將日期和時間存儲在單獨的列中,因此我創建了名稱爲data1和列(dis string,dat date,time string)的另一個表。我怎樣才能從表格數據複製數據到data1。 我曾試圖通過做「插入到表data1選擇dis,轉換(日期,dt),轉換(時間,dt)從數據;」。如何從時間戳中分離日期和時間,並將其存儲在配置單元中的另一個表中
0
A
回答
0
下面查詢使用
insert into table data1 select dis,TO_DATE(dt),concat(HOUR(DT),':',MINUTE(dt)) from data;
0
select dis,to_date(dt),split(dt,' ')[1]
或
select dis,to_date(dt),substr(dt,12,8)
演示
with t as (select timestamp '2017-04-06 04:20:33' as dt)
select to_date(dt),split(dt,' ')[1] from t;
OK
_c0 _c1
2017-04-06 04:20:33
with t as (select timestamp '2017-04-06 04:20:33' as dt)
select to_date(dt),substr(dt,12,8) from t;
OK
_c0 _c1
2017-04-06 04:20:33
相關問題
- 1. 如何將日期值存儲在配置單元時間戳中?
- 2. 分離的日期和時間的日期時間戳
- 3. 如何從日期時間剝離時間並使用Python存儲在PSQL中?
- 4. 從日期時間格式中分離日期和時間mysql
- 5. 如何合併來自一個時間戳的日期和來自另一個時間戳的時間?
- 6. 從一個日期時間和另一個日期時間的合併日期
- 7. 如何從日期時間戳的時間和日期在PHP
- 8. 無法將日期和時間戳記值存儲在mysql中
- 9. 從配置單元中的時間戳獲取時間
- 10. 如何在HDFS中存儲和分析時間戳日誌
- 11. 如何提取配置單元中的日期和時間
- 12. 如何在MySql時間戳中存儲java日曆時間?
- 13. 將日期和時間添加到MySQL中的時間戳中
- 14. 如何從日期時間戳得到時間和日期
- 15. 如何從另一個日期時間減去日期時間?
- 16. 在tarantool中存儲日期和時間
- 17. 配置單元hbase積分時間戳
- 18. 如何在SQL Server中存儲Oracle時間戳精度6日期時間
- 19. 如何將日期時間轉換爲java中的時間戳
- 20. 在JDBC中,何時使用時間,日期和時間戳
- 21. 將日期時間從mySql更改爲php中的時間戳
- 22. 如何從Unix時間戳設置日期/時間在bash
- 23. 無法獲取從PHP中的時間戳日期和時間?
- 24. 如何在memsql中存儲時間戳?
- 25. 如何在存儲過程中設置日期時間時區
- 26. 選擇amountofpersons其中的日期和分離時間與SQL日期/分離的時間C#相比
- 27. Java日期處理:在單個類中存儲日期,時間和時區
- 28. 從系統中拆分日期和時間::日期時間
- 29. 如何將日期時間轉換爲時間戳紀元
- 30. 如何在Swift中分離NSDate()的日期和時間組件?
(1)什麼用秒? (2)爲什麼使用'concat'而不是'concat_ws'? –
我剛剛提供樣品以包括時間,我們可以根據我們的要求使用。是的,我們也可以使用concat_ws ..謝謝 –