zoukankan      html  css  js  c++  java
  • hive中 日期格式转化办法小记

    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;

  • 相关阅读:
    [NOI2008] 糖果雨
    [NOI2006] 神奇口袋
    [NOI2014] 购票
    Prince and Princess HDU
    Network POJ
    CodeForces
    Codeforces Global Round 12
    Codeforces Round #688 (Div. 2)
    [USACO05DEC]Layout G
    # Technocup 2021
  • 原文地址:https://www.cnblogs.com/oraser/p/7647935.html
Copyright © 2011-2022 走看看