hive DATEDIFF NULL

xiaoxiao2021-02-28  6

感谢分享:

  http://blog.csdn.net/yukangmine/article/details/47313215

  http://blog.csdn.net/lxpbs8851/article/details/40981743

select datediff("20150806","20150706") from test;   结果全是NULL

亲,请更改格式,请更改格式,请更改格式,重要的事情说3遍

select datediff("2015-08-06","2015-07-06") from test;   

hive中 日期格式转化办法: 2014-11-10 和 20141110相互转化的办法: 1.from_unixtime && unix_timestamp -- 20141110 select from_unixtime(unix_timestamp('2014-11-10','yyyy-mm-dd'),'yyyymmdd') from default.dual; -- 2014-11-10 select from_unixtime(unix_timestamp('20141110','yyyymmdd'),'yyyy-mm-dd') from default.dual; 2.substr + concat -- 20141110 select concat(substr('2014-11-10',1,4),substr('2014-11-10',6,2),substr('2014-11-10',9,2)) from default.dual; -- 2014-11-10 select concat(substr('20141110',1,4),'-',substr('20141110',5,2),'-',substr('20141110',7,2)) from default.dual;

 

附加:hive 获取当前时间

select from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss') from default.dual;

转载请注明原文地址: https://www.6miu.com/read-850361.html

最新回复(0)