添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
--20171205转成2017-12-05 select from_unixtime(unix_timestamp('20171205','yyyyMMdd'),'yyyy-MM-dd') from dual; --2017-12-05转成20171205 select from_unixtime(unix_timestamp('2017-12-05','yyyy-MM-dd'),'yyyyMMdd') from dual;
方法2: substr + concat
--20171205转成2017-12-05 
select concat(substr('20171205',1,4),'-',substr('20171205',5,2),'-',substr('20171205',7,2)) from dual;
--2017-12-05转成20171205
select concat(substr('2017-12-05',1,4),substr('2017-12-05',6,2),substr('2017-12-05',9,2)) from dual;
方法3: split + concat_ws(concat不行)
--2019-01-03转成20190103
select concat_ws('',split('2019-01-03','-'));
方法4: regexp_replace
--2019-01-03转成20190103
select regexp_replace('2019-01-03','-','');
方法1: from_unixtime+ unix_timestamp--20171205转成2017-12-05 select from_unixtime(unix_timestamp('20171205','yyyyMMdd'),'yyyy-MM-dd') from dual;--2017-12-05转成20171205select from_unixtime(unix_times...
regexp_replace(‘2017-12-05’,’-’,’’) set belong_month=2020-04; date_format(concat(year(’hiveconf:belongmonth′)−1,′−′,month(′{hiveconf:belong_month}')-1,'-',month('hiveconf:belongm​onth′)−1,′−′,month(′{hiveconf:belong_month}’)),‘yyyy-MM’) 感觉这个可以用date函数去做。
获取当前时间并转换为yyyy-mm-dd格式 select from_unixtime(unix_timestamp(),'yyyy-MM-dd') select from_unixtime(unix_timestamp(),'yyyyMMdd') //这里的MM必须大写 yyyymmdd格式转换为yyyy-mm-dd regexp_replace('$n_date','-',"")...
HiveyyyyMMdd变成yyyy-MM-dd: select to_date(from_unixtime(UNIX_TIMESTAMP('20210101','yyyyMMdd'))); 2021-01-01
一. 日期>>>>时间戳 unix_timestamp(string date,string pattern) 将指定时间字符串格式字符串转化成unix时间戳,如不符合则返回null select unix_timestamp('2019-08-15','yyyy-MM-dd') --1565798400 select unix_timestamp('2019-08-15 16:40:00','yyyy-MM-dd HH:mm:ss') --1565858400 时间戳转成日期 hive : select distinct from_unixtime(1441565203,‘yyyy/MM/dd HH:mm:ss’) from test_date; sqlSever: CONVERT ( VARCHAR ( 10 ), DATEADD ...
--20171205转成2017-12-05 select from_unixtime(unix_timestamp('20171205','yyyyMMdd'),'yyyy-MM-dd') from dual; --2017-12-05转成20171205 select from_unixtime(unix_timestamp('2017-12-05','yyyy-MM-dd'),'yyyyMMdd') from dual;.
日期计算平时在业务取数时经常涉及到,但是数据库经常存放着不同的日期格式,有的存放是时间戳、有的是字符串等,这时需要对其进行转换才能提取到准确的数据,这里介绍的均是hive里面的函数功能,以下内容均是业务的数据需求经常使用的部分 unix时间戳是从1970年1月1日(UTC/GMT的午夜)开始所经过的秒数,不考虑闰秒,一般为10位的整数 一个在线工具:https://tool.l...
--20171205转成2017-12-05 select from_unixtime(unix_timestamp('20171205','yyyymmdd'),'yyyy-mm-dd') from dual; --2017-12-05转成20171205 select from_unixtime(unix_time... 1. 使用substr函数将原始日期字符串的年、月、日分别提取出来,例如: select substr('20220101', 1, 4) as year, substr('20220101', 5, 2) as month, substr('20220101', 7, 2) as day; 这样就可以得到年、月、日分别为2022、01、01的结果。 2. 使用concat函数将年、月、日拼接成新的日期字符串,例如: select concat(substr('20220101', 1, 4), '-', substr('20220101', 5, 2), '-', substr('20220101', 7, 2)) as new_date; 这样就可以得到新的日期字符串为2022-01-01的结果。 综合起来,可以使用如下的Hive SQL语句将yyyymmdd转成yyyy-mm-dd: select concat(substr(date_str, 1, 4), '-', substr(date_str, 5, 2), '-', substr(date_str, 7, 2)) as new_date from table_name; 其,date_str为原始日期字符串,table_name为包含原始日期字符串的表名。 $HADOOP_PREFIX/sbin/start-dfs.sh 启动失败,卡在node2: starting datanode, logging to …… 2301_80613504: 想知道怎么重新操作的呀,也是启动hdfs卡在那儿半天了 【算法】狄利克雷过程 (Dirichlet过程) m0_58126930: 【Word】首行调整段前距无效 qq_36603539: 没有段前的前面加连续分隔符有效!!!!终于解决了