【HIVE】各种时间格式处理
yyyy-MM-dd与yyyyMMdd000000转换的三种方法
方法一:date_format(只支持yyyy-MM-dd -> yyyyMMdd000000)
select date_format('2019-10-07', 'yyyyMMdd000000')
--
方法二:from_unixtime + unix_timestamp
select from_unixtime(unix_timestamp('2019-10-07', 'yyyy-MM-dd'), 'yyyyMMdd000000')
--
select from_unixtime(unix_timestamp(substr('',1,8),'yyyyMMdd'),'yyyy-MM-dd')
-- 2019-10-07
方法三:substr + concat
select concat(substr('2019-10-07',1,4),substr('2019-10-07',6,2),substr('2019-10-07',9,2),'')
--
select concat(substr('',1,4),'-',substr('',5,2),'-',substr('',7,2))
-- 2019-10-07
时间转换方法详解
unix_timestamp:格式化日期转时间戳
select unix_timestamp('2019-10-07 13:24:20','yyyy-MM-dd HH:mm:ss')
--
select unix_timestamp('','yyyyMMdd')
--
from_unixtime:时间戳转格式化日期
select from_unixtime(1570425860,'yyyy-MM-dd HH:mm:ss')
-- 2019-10-07 13:24:20 select from_unixtime(1570425860,'yyyyMMdd000000')
--
date_format:yyyy-MM-dd HH:mm:ss 时间转格式化时间
select date_format('2019-10-07 13:24:20', 'yyyyMMdd000000')
--
select date_format('2019-10-07', 'yyyyMMdd000000')
--
yyyy-MM-dd HH:mm:ss 注意
MM为月份
mm为分钟
HH为24小时制
hh为12小时制
【HIVE】各种时间格式处理的更多相关文章
- python获取hive表时间格式最大分区
#获取表的最大分区 import boto3 from datetime import datetime,timedelta def get_max_partition(db_name,table_n ...
- hive笔记:时间格式的统一
一.string类型,年月日部分包含的时间统一格式: 原数据格式(时间字段为string类型) 取数时间和格式的语法 2018-11-01 00:12:49.0 substr(regexp_repl ...
- 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中时间操作(一)
转:https://blog.csdn.net/u012474716/article/details/78925319/ hive中常用的时间为时间戳和日期格式之间的转换 常用的函数为: to_dat ...
- sql的时间格式
sql中的时间格式转换主要有:date_format函数,str_to_date函数 1. 首先选择一个数据库 use db_name; 2. 显示当前时区的时间: SELECT NOW(); 3. ...
- NSDateFormatter 时间格式转换
NSString *strDate = @“Wed Apr ::”; NSDateFormatter *dateFomatter =[[NSDateFormatter alloc] init]; [d ...
- 时间格式转换—将后台返回的/Date(1448954018000)/格式转换为正常的时间格式
用JS实现方法: function ChangeDateFormat(cellval) { )); < ? ) : date.getMonth() + ; ? " + date.get ...
- Newtonsoft.Json 序列化和反序列化 时间格式【转】
1.JSON序列化 string JsonStr= JsonConvert.SerializeObject(Entity); eg: A a=new A(); a.Name="Elain ...
- Spring mvc时间格式处理
spring mvc中,如果时间格式是yyyy-MM-dd,传入后台会报错,要增加一些配置才可以. 1.修改spring-mvc.xml,增加org.springframework.format.su ...
- db2 日期时间格式
db2日期和时间常用汇总 1.db2可以通过SYSIBM.SYSDUMMY1.SYSIBM.DUAL获取寄存器中的值,也可以通过VALUES关键字获取寄存器中的值. SELECT 'HELLO DB2 ...
随机推荐
- Solr7.0搭建过程
小李经过Elasticsearch和solr之我为什么选择solr之后决定使用使用Solr作为项目的搜索引擎,然后和同事们开始讨论细节问题. 小李:虽然我会solr4.7版本的搭建,但是人总要有点梦想 ...
- [python]python子字符串的提取、字符串连接、字符串重复
1. python使用索引运算符[]和切片运算符[:],来提取字符串. 第一个字符的索引是0,最有一个字符的索引是-1,切片运算符[x:y]表示提取从索引x到索引y-1的字符,不包含索引y. 示例: ...
- ZOJ-3872-Beauty of Array-思维
ZOJ-3872-Beauty of Array 传送门:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3872 参考:ht ...
- 牛客小白月赛6 J 洋灰三角 数学
链接:https://www.nowcoder.com/acm/contest/136/J来源:牛客网 题目描述 洋灰是一种建筑材料,常用来筑桥搭建高层建筑,又称,水泥.混凝土. WH ...
- CF985C Liebig's Barrels 贪心 第二十
Liebig's Barrels time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- CF993A Two Squares 几何 第二道 暴力或判断条件(*)
Two Squares time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- 【Windows】PostgreSql安装
Installer安装包问题 Problem running post-install step. Installation may not complete correctly. The datab ...
- Integer和Integer常量池
Integer中有个静态内部类 IntegerCache ,里面有个cache[],也就是Integer常量池 大小为一个字节(-128-127). (jdk1.8.0_101)源码 private ...
- sublime,webstrom,vscode的使用感受,以及对于vue和webpack的支持,还有一些快捷键使用心得
从最开始用sublime3到webstrom再到vscode,我的感觉如下: sublime首次加载项目文件速度较快,每次装插件有点麻烦,插件很丰富,也很好用. webstrom首次加载项目文件速度奇 ...
- 字符串的api (基础)
一.基础 1.字符串.charAt(index) 根据下标获取字符串的某一个字符 应用: 判断字符串的首字母是否大写 任意给定的一串字母,统计字符串里面的大写字母和小写字母的个数 2.字符串.inde ...