zoukankan      html  css  js  c++  java
  • presto 将20210101 转为日期

    -- presto 

     1 SELECT var
     2 ,IF(strpos(var,'-')>0,date(substring(var,1,10)),CAST(parse_datetime(CAST(substring(var,1,10) AS varchar), 'yyyyMMdd') AS date) )
     3 ,'IF(strpos('||var||','||''''||'-'||''''||')>0,date(substring('||var||',1,10)),CAST(parse_datetime(CAST(substring('||var||',1,10) AS varchar),'|| ''''||'yyyyMMdd'||''''||') AS date))>=current_date - INTERVAL '||'''' || '60' ||''''||' DAY ' 
     4 ,IF(strpos(var,'-')>0,date(substring(var,1,10)),CAST(parse_datetime(CAST(substring(var,1,10) AS varchar),'yyyyMMdd') AS date) )
     5 --,CAST(parse_datetime(CAST(var AS varchar), 'yyyyMMdd') AS date)
     6 ,CAST(parse_datetime(CAST(var AS varchar), 'yyyyMMdd') AS date) 
     7 FROM (
     8 --SELECT '2021-01-01' var  UNION ALL 
     9 SELECT '20210101' var   
    10 )

    -- mysql 

    select 'ods_t_jdsz_cus_daily', count(*)
    from ods_t_jdsz_cus_daily
    where IF(instr(last_modify_time,'-')>0,date(substring(last_modify_time,1,10)),str_to_date(substring(last_modify_time,1,10),'%Y%m%d') )>=current_date - INTERVAL '3' DAY

  • 相关阅读:
    Mybatis分页插件
    Mybatis代码自动生成
    Spring-Mybatis依赖
    Spring-test单元测试
    Spring-json依赖
    Spring-MVC依赖
    Log4j日志依赖
    Spring数据库连接池依赖
    Spring-JDBC依赖
    Spring依赖
  • 原文地址:https://www.cnblogs.com/linbo3168/p/15108581.html
Copyright © 2011-2022 走看看