hive时间
Hive中日期函数总结:
1.时间戳函数
日期转时间戳:从1970-01-01 00:00:00 UTC到指定时间的秒数
select unix_timestamp(); --获得当前时区的UNIX时间戳
select unix_timestamp('2017-09-15 14:23:00');
select unix_timestamp('2017-09-15 14:23:00','yyyy-MM-dd HH:mm:ss');
select unix_timestamp('20170915 14:23:00','yyyyMMdd HH:mm:ss');
--时间戳转日期
select from_unixtime(1505456567);
select from_unixtime(1505456567,'yyyyMMdd');
select from_unixtime(1505456567,'yyyy-MM-dd HH:mm:ss');
select from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss'); --获取系统当前时间
2.获取当前日期: current_date
hive> select current_date from dual
2017-09-15
3.日期时间转日期:to_date(string timestamp)
hive> select to_date('2017-09-15 11:12:00') from dual;
2017-09-15
3.获取日期中的年/月/日/时/分/秒/周
with dtime as(select from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss') as dt)
select year(dt),month(dt),day(dt),hour(dt),minute(dt),second(dt),weekofyear(dt)
from dtime
4.计算两个日期之间的天数: datediff
hive> select datediff('2017-09-15','2017-09-01') from dual;
14
5.日期增加和减少: date_add/date_sub(string startdate,int days)
hive> select date_add('2017-09-15',1) from dual;
2017-09-16
hive> select date_sub('2017-09-15',1) from dual;
2017-09-14
其他日期函数
查询当前系统时间(包括毫秒数): current_timestamp;
查询当月第几天: dayofmonth(current_date);
月末: last_day(current_date)
当月第1天: date_sub(current_date,dayofmonth(current_date)-1)
下个月第1天: add_months(date_sub(current_date,dayofmonth(current_date)-1),1)
hive时间的更多相关文章
- Hive 时间操作
Hive 时间转换 UNIX时间戳概念:因为UNIX时间戳只是一个秒数,一个UNIX时间戳在不同时区看来,时间是不同的.如UNIX时间戳0,在0时区看来是1970-01-01 00:00:00,在东八 ...
- Hive时间操作[转]
时间字段格式化 from_unixtime(unix_timestamp(VisitTime),'yyyy-MM-dd') 日期函数UNIX时间戳转日期函数: from_unixtime语法: f ...
- HIVE 时间操作函数
转自http://www.oratea.net/?p=944 日期函数UNIX时间戳转日期函数: from_unixtime语法: from_unixtime(bigint unixtime[, ...
- Hive 时间日期处理总结
最近用hive比较多,虽然效率低,但是由于都是T+1的业务模式.所以也就不要求太多了,够用就行.其中用的吧比较多就是时间了,由于大数据中很多字段都不是标准的时间类型字段,所以期间涉及了很多的时间日期字 ...
- hive时间日期函数及典型场景应用
1.hive取得当前日期时间: 1.1) 取得当前日期: select current_date(); 1.2) 取得当前日期时间: select current_timestamp(); 1.3) ...
- Hive 时间函数总结【转】
1.日期函数UNIX时间戳转日期函数: from_unixtime语法:from_unixtime(bigint unixtime[, stringformat]) 返回值: string说明: 转化 ...
- Hive presto和hive时间格式转换
1.北京时间格式 to unix时间格式 数据格式: 2017-11-17 08:28:13 2017-11-17 08:28:10 2017-11-17 08:27:51.343 2017- ...
- Hive 时间操作函数(转)
1.日期函数UNIX时间戳转日期函数: from_unixtime 语法: from_unixtime(bigint unixtime[, string format]) 返回值: string ...
- hive 时间函数
使用时发现:1.datediff可以传入timestamp类型参数 官网文档: Date Functions The following built-in date functions are ...
随机推荐
- PS学习一
1.使用缩放工具时是对文档窗口进行的缩放,它只影响视图比例:而对图像的缩放则是指对图像文件本身进行的物理缩放,它会使图像的内容变大或变小. 2.分辨率是指单位长度内包含的像素点的数量,它的单位通常为像 ...
- redis 的安装及常用的命令
前言: redis是一个key-value的存储系统,value支持string.list.set.zset.hash五种类型,且支持数据的本地存储 一.安装redis 前提:linux下需要安装了m ...
- 运维笔记:zabbix的运用(1)安装过程
前言 如果是用了阿里云或者腾讯云,他们都有各种监控帮我们做好.但是如果是遇到了自己维护自己机房的服务器,那么一些可视化或者监控就很有意义了.监控可能有很多种方案,这里就以比较老牌通吃的zabbix来解 ...
- 将scl分频
多个scl后一个高脉冲,脉冲宽度一个scl脉冲. always @ ( posedge MCLK or negedge RST_N ) begin if (rClkCount == 24) //如果有 ...
- 多光源 MultipleLight
使用2个Pass增加光照效果: 第一个Pass是基础光源,一般是第一个平行光:Tags{"LightMode" = "ForwardBase"} 第二个光源是增 ...
- hdu 1179最大匹配
#include<stdio.h> #include<string.h> #define N 200 int map[N][N],visit[N],link[N],n,m; i ...
- MySQL数据库:SQL语句基础、库操作、表操作、数据类型、约束条件、表之间的关系
数据库相关概念: 1. 数据库服务器:运行数据库管理软件的计算机 2. 数据库管理软件:MySQL.Oracle.db2.slqserver 3. 库:文件夹,用来组织文件/表 4. 表:文件(类似于 ...
- linux 常见名词及命令(五)
计划任务服务之一次性任务: at <时间> 安排一次性任务 atq 或at -l 查看任务列表 at -c 序号 预览任务与设置环境 atrm 序号 删除任务 安排任务示例: 在23:30 ...
- 组队训练1 回放(转载至cxhscst2's blog)
第一场组队训练……意料之中的爆炸. 开场先看题,H是斐波那契水题,qw把H切了. 同时czy看I题(排列),cst继续读其他题. czy尝试交I,PE. cst发现K是水题. cst上来敲K,WA ...
- SpringBoot学习day01
SpringBoot目的在于创建和启动新的基于Spring框架的项目.SpringBoot会选择最合适的Spring子项目和第三方开源库进行整合.大部分SpringBoot应用只需要非常少量的配置就可 ...