Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 20 Sep 2012 @ 11:03:05 GMT


     
  <Prev Next>  
<<First
<Prev
Next> Last>>  


Subj:   add_months for integer-type dates
 
From:   Napflin Markus

Hi All,

We're often dealing with monthly data. That's why our DWH architect decided to define dates as integer of the format YYYYMM.

Now I'm looking for an easy way to add/subtract months (for building a UDF). Best idea so far is this:

     select 201209 as year_month_n, 1 as x
       , cast((year_month_n - 190000) * 100 + 1 as DATE) a
       , add_months(a,x) b
       , cast(b/100 + 190000 as INTEGER) as c

I'm sure there is a simpler way?


Thanks - Markus



     
  <Prev Next>  
<<First
<Prev
Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023