日期:
SELECT unix_timestamp('2017-12-01 00:15:30') # 1512058530
select from_unixtime(1512058530) # 2017-12-01 00:15:30
select from_unixtime(1512058530,'yyyy-MM-dd') # 2017-12-01
select to_date('2017-12-01 00:15:30') # 2017-12-01
select year('2017-12-01 00:15:30') /*同样使用month、day、hour、minute、second # 2017
select datediff('2017-12-01 00:15:30','2017-11-01 00:15:30') # 30
select date_add('2017-12-01 00:15:30',30) # 2017-12-31
select date_sub('2017-12-01 00:15:30',30) # 2017-12-31
select weekofyear('2017-12-01 00:15:30') /*该日期为本年第几周 # 48
select cast(from_unixtime(cast(1512058530000/1000 as bigint),'yyyy-MM-dd HH:mm:ss') as timestamp)/*整数类型转换为日期 #2017-12-01 00:15:30
select cast(from_unixtime(cast(1512058530000/1000 as bigint),'yyyy-MM-dd') as date) /*浮点数类型转换为日期 #2017-12-01
set hive.exec.stagingdir=/tmp/hive-staging;
hive.exec.stagingdir设置为.hive-staging时,由于临时目录在目标目录下面,所以创建临时目录时,会先创建目标目录,不存在目标目录不存在的问题。
HIVE日期代码
最新推荐文章于 2022-07-28 09:16:10 发布