Hive中unix_timestamp和from_unixtime的用法

unix_timestamp 将某种格式的时间转换为时间戳

  用法:unix_timestamp(String str)

  如果参数str格式满足yyyy-MM-DD HH:mm:ss格式,例如:str值为2020-02-02 02:02:02,用法为 select unix_timestamp(2020-02-02 02:02:02);

  

  如果参数str格式不满足yyyy-MM-DD HH:mm:ss格式,例如:str值为2020-02-02,用法为 select unix_timestamp(‘2020-02-02’,'yyyy-MM-DD');

  

 

from_unixtime 不同时间格式的相互转换

  用法:from_unixtime(bigint i,String str),第一个参数 i 必须是10位数,如果是13位数需要截取转换。

  

 

posted on 2020-02-12 11:18  吴玉川  阅读(4436)  评论(0)    收藏  举报