Hive 日期函数
来源:互联网 发布:thumbdata怎么删除知乎 编辑:程序博客网 时间:2024/05/21 12:05
对于日期时间的操作,记录一下:
1、 unix时间戳 ⇋ 日期(string)
unix时间戳 —->日期
from_unixtime(unixtime, format)
默认格式是:yyyy-MM-dd HH:mm:ss 1970-01-01 00:00:00
hive> select from_unixtime(1323308943,’yyyyMMdd’) from dual;
20111208
日期 —->unix时间戳
unix_timestamp(string date, string pattern) 转换pattern格式的日期到时间戳
默认格式是:yyyy-MM-dd HH:mm:ss 1970-01-01 00:00:00
hive> select unix_timestamp(‘20111207 13:01:03’,’yyyyMMdd HH:mm:ss’)
from dual; 1323234063
2、日期转年,月,日等
•日期时间转日期函数: to_date(string timestamp),返回值: string
hive> select to_date(‘2011-12-08 10:03:01’) from dual;
2011-12-08
•日期转年函数: year(string date),返回值: int
hive> select year(‘2011-12-08 10:03:01’) from dual;
2011
hive> select year(‘2012-12-08’) from dual;
2012
• 日期转月函数: month(string date),返回值: int
• 日期转天函数: day(string date),返回值: int
• 日期转小时函数: hour(string date),返回值: int
• 日期转分钟函数: minute(string date),返回值: int
• 日期转秒函数: second(string date),返回值: int
• 日期转周函数: weekofyear(string date),返回值: int
3、日期比较,加,减
• 日期比较函数: datediff(string enddate, string startdate), 返回值: int
hive> select datediff(‘2012-12-08’,’2012-05-09’) from dual;
213
• 日期增加函数: date_add(string startdate, int days),返回值: string
hive> select date_add(‘2012-12-08’,10) from dual;
2012-12-18
• 日期减少函数: date_sub(string startdate, int days),返回值: string
参考链接:http://sishuok.com/forum/blogPost/list/6222.html
- hive日期函数
- hive 日期函数小结
- Hive日期函数
- Hive 日期函数 weekofyear
- HIVE日期函数
- [HIve]日期相关函数
- hive日期函数
- [转载]Hive日期函数
- hive日期函数 整理
- Hive(八)--日期函数
- hive日期函数总结
- Hive 之 日期函数
- Hive 日期函数
- Hive --- 日期函数
- Hive日期函数
- Hive日期函数
- Hive常用日期函数整理
- Hive日期时间函数学习
- 使用scp向Linux服务器传送文件
- Linux下载 安装cadenceIC617
- 算法1-2:棋盘覆盖问题
- 灵活&&高效的符号表--二叉查找树
- dropout和L1,L2正则化的理解笔记
- Hive 日期函数
- Longest Continuous Increasing Subsequence
- css知识点——文本溢出的处理方法
- [模板] Dijkstra单源最短路径
- QML中的Menu
- PYTHON机器学习实战——K均值聚类
- 闭锁机制
- python中的break语句
- Cesium学习(二)shp格式转为json格式并叠加到底图上使用