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;
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值