hive中常用字符串转时间的处理方法

数据

2018-11-01 07:57:33

1、使用hive内置的时间日期函数完成数据ETL。

select 
    to_date(time_local) as daystr,
    date_format(time_local,'HH:mm:ss'),
    month (time_local)as month,
    day (time_local)as day,
    hour (time_local)as hour 
from 
	ods_weblog_origin 
limit 
	50;
select 
    to_date(time_local) as daystr,
    date_format(time_local,'HH:mm:ss') as tmstr,
    date_format(time_local,'MM')as month,
    date_format(time_local,'dd')as day,
    date_format(time_local,'HH')as hour
from 
	ods_weblog_origin 
limit 
	50;

2、使用字符串的截取完成数据ETL。

select 
    substring(time_local,0,10) as daystr,
    substring(time_local,12) as tmstr,
    substring(time_local,6,2) as month,
    substring(time_local,9,2) as day,
    substring(time_local,12,2) as hour 
from 
	ods_weblog_origin 
limit 
    50;

版权声明:本文为qq_36382679原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。