zoukankan      html  css  js  c++  java
  • Hive中yyyymmdd和yyyy-mm-dd日期之间的切换

    以2017-12-05和20171205相互转换为例说明

    方法1: from_unixtime+ unix_timestamp
    --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;
  • 相关阅读:
    JS-07 (js的面向对象编程)
    AI SiameseFC
    phpstorm调试
    Php 编译扩展
    canvas
    AI FCN
    AI WebGL
    Python flask
    JIT 即时编译
    小程序
  • 原文地址:https://www.cnblogs.com/huangbiquan/p/7989974.html
Copyright © 2011-2022 走看看