数据仓库服务 GAUSSDB(DWS)-Teradata格式:以YYYYDDD格式输入日期

时间:2024-10-26 11:41:22

以YYYYDDD格式输入日期

输入

输出

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
REPLACE VIEW SC.VIEW_1 
 ( 
 col_1 
 ) 
 LOCKING TABLE sc.tab FOR AC CES S 
 AS 
 SEL 
 --tgt.col_1 is date type 
 CAST( CAST(TGT.col_1 AS DATE FORMAT 'YYYYDDD') AS CHAR(7) ) AS col_1 
 FROM 
 sc.tab TGT 
 ;
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
CREATE 
      OR REPLACE VIEW SC.VIEW_1 (col_1)  
     /*LOCKING TABLE sc.tab FOR ACCESS */ 
      AS ( 
           SELECT 
                     /* tgt.col_1 is date type */ 
                     CAST( TO_DATE(TGT.col_1, 'YYYYDDD') AS CHAR( 7 ) ) AS col_1 
                FROM 
                     sc.tab TGT 
      ) ;
support.huaweicloud.com/tg-dws/dws_16_0101.html