我有下表结构:
Table name: test
表结构:这里的col1和col2是字符串。
col1 | col2 |
---|---|
“abc” | “15/04/2016” |
“定义” | “2016年5月31日” |
当我尝试执行下面的代码时,结果显示为 NULL。
select to_date(col2) from test;
知道为什么它没有显示 col2 结果吗?
尝试以下操作:
SELECT to_date(FROM_UNIXTIME(UNIX_TIMESTAMP(col2,'dd/MM/yyyy')))
to_date(String timestamp)
期望时间戳采用以下格式:yyyy-mm-dd hh:mm:ss
请参阅Hive 日期函数了解更多详细信息。