赞
踩
1、时间戳转日期函数:to_date
语法:to_date(string timestamp)
说明:将标准格式时间戳转成日期格式
举例:
hive> select to_date('2019-06-21 13:21:13') from dual;
OK
2019-06-21
Time taken: 0.102 seconds, Fetched: 1 row(s)
2、unix时间戳转成当前时区时间格式:from_unixtime
语法:from_unixtime(timestamp,string format)
说明:unix时间戳timestamp转成当前时区时间格式format
举例:
hive> select from_unixtime(1123240993,'yyyyMMdd HH:mm:ss') from dual;
OK
20050805 19:23:13
3、当前时区时间转unix时间戳:unix_timestamp
语法:unix_timestamp([date],[dateformat])
说明:当前时区时间转unix时间戳,formate为时间取位范围
举例:
hive> select unix_timestamp('2019-06-15 14:12:00') from dual;
OK
1560579120
Time taken: 0.091 seconds, Fetched: 1 row(s)
hive> select unix_timestamp('2019-06-15 14:12:00','yyyy-MM-dd') from dual;
OK
1560528000
Time taken: 0.108 seconds, Fetched: 1 row(s)
hive> select unix_timestamp('2019-06-15 14:12:00','yyyy-MM-dd HH:mm:ss') from dual;
OK
1560579120
Time taken: 0.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。