hive 时间戳函数之unix_timestamp,from_unixtime
2024-10-09 06:30:41
一. 日期>>>>时间戳 1.unix_timestamp() 获取当前时间戳
例如:select unix_timestamp() --
2.unix_timestamp(string timestame) 输入的时间戳格式必须为'yyyy-MM-dd HH:mm:ss',如不符合则返回null
例如:
select unix_timestamp('2019-08-15 16:40:00') --
select unix_timestamp('2019-08-15') --null
3.unix_timestamp(string date,string pattern) 将指定时间字符串格式字符串转化成unix时间戳,如不符合则返回null
例如:
select unix_timestamp('2019-08-15','yyyy-MM-dd') -- select unix_timestamp('2019-08-15 16:40:00','yyyy-MM-dd HH:mm:ss') -- select unix_timestamp('2019-08-15','yyyy-MM-dd HH:mm:ss') --null
二. 时间戳>>>>日期 1.from_unixtime(bigint unixtime,string format) 将时间戳秒数转化为UTC时间,并用字符串表示,可通过format规定的时间格式,指定输出的时间格式,其中unixtime 是10位的时间戳值,而13位的所谓毫秒的是不可以的。
例如:
select from_unixtime(,'yyyy-MM-dd HH:mm:ss') ---- :: select from_unixtime(,'yyyy-MM-dd') ----
2.如果unixtime为13位的,需要先转成10位
select from_unixtime(cast(/ as int),'yyyy-MM-dd HH:mm:ss') ---- :: select from_unixtime(cast(substr(,,) as int),'yyyy-MM-dd HH:mm:ss') ---- ::
三.获取当前时间
select from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss') -- -- ::
最新文章
- 点(x3,y3)到经过点(x1,y1)和点(x2,y2)的直线的最短距离
- 前台JS(type=‘file’)读取本地文件的内容,兼容各种浏览器
- if条件里比较浮点数
- [转载] linux下打开windows txt文件中文乱码问题
- hdu1059 Dividing ——多重背包
- WordPress主题制作教程10:添加文章类型插件Custom Post Type UI
- 巧妙使用Jquery 改变元素的 onclick 事件
- make xxx Is a directory. Stop.
- java代码如何快速添加作者描述的注释最好能有详细的图解
- 贪吃蛇AI
- MySQL数据目录更改及相关问题解决方案
- Robot Framework学习笔记(十)------Selenium2Library库
- JAVA_SE基础——47.接口
- [BZOJ 4403]序列统计
- poj 2886 线段树+反素数
- Sql Server 查询库表记录数
- CertUtil.exe被利用来下载恶意软件
- shell中set的用法(转)
- EXCEPTION-SPRING
- 《OD大数据实战》Spark入门实例
热门文章
- Java实现 蓝桥杯 算法训练 数据交换
- Java实现分割矩形
- java实现拼出漂亮的表格
- Java实现格子取数问题
- Python 图像处理 OpenCV (7):图像平滑(滤波)处理
- npm run dev启动项目,electron提示throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
- CentOS8.1中搭建Gitlab服务器
- 轻量级进度条 – Nprogress.js
- FFT,NTT入门
- BrainF**k的编译器