首页 > 其他 > 详细

培训系列15--hive 对 date类型的处理

时间:2018-12-12 17:04:09      阅读:200      评论:0      收藏:0      [点我收藏+]

一。基础日期处理

//date 日期处理
select current_date;
select current_timestamp;
//to_date(time) ;to_date(string)
select to_date(current_timestamp);
select to_date(rental_date) from rental limit 10;
month(date/time)
year(date/time)
day(date/time)
second(time)
minute(time)
hour(time)

select hour("22:32:34.0");
select hour(rental_date),count(hour(rental_date)) counts from rental group by hour(rental_date) order by counts;
//注意order by的字段必须要有名字或者别名
unix_timestamp(timestamp)
from_unixtime(unixtime)

//两种时间格式互转
to_utc_timestamp(timestamp,"EST")
from_utc_timestamp(timestamp,"EST")
//于标准时间之间的互转
select unix_timestamp();
select unix_timestamp(current_timestamp);
select from_unixtime(unix_timestamp(current_timestamp));
select from_utc_timestamp(to_utc_timestamp(current_timestamp,"EST"),"EST"),current_timestamp;

二、高级日期时间格式的处理

 

培训系列15--hive 对 date类型的处理

原文:https://www.cnblogs.com/davidzhu/p/10109250.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!