Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 23 Aug 2012 @ 09:36:18 GMT


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


Subj:   Re: How to replace with null if date is invalid
 
From:   Carlos Carpio Garcia

As I understand, the input field must be a character , since '2012-30-30' is not allowed in a date field.

What I would do is selecting a subset of SYS_CALENDAR.CALENDAR and typecasting the date to CHAR in order to do the comparisons.

If your table was called TEST_TABLE with a character(10) TEST_DATE field, I'd do something like this.

     Select
       TEST_DATE,
       calendar_date
     From
       TEST_TABLE Left Join
     (
     Select
       calendar_date (Date, Format 'yyyy-mm-dd') (Char(10)) txt_date,
       calendar_date
     From
       SYS_CALENDAR.CALENDAR
     Where
       calendar_date Between '1950-01-01' And Add_Months(Date,5*12)
     ) On
       TEST_DATE=txt_date
     ;

Carlos Carpio Garcia
"la Caixa" Servicios Centrales / Tecnolog?a



     
  <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