Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 28 Mar 2009 @ 02:01:13 GMT


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


Subj:   Re: Casting to Integer Question
 
From:   McCall, Glenn David

I had a similar question in relation to dates. For example '2009-03-28x' didn't generate an invalid date error message. The general consensus was that there was an implicit format that excluded the trailing characters. However, '2009-03-28x1' did generate an invalid date message.

Curiously the following also "work"

     select cast ('2/1' as integer);   = 21
     select cast ('2//1' as integer);  = 21
     select cast ('2//1' as integer) - 2; = 19
     select type(cast ('2//1' as integer)); = integer
     select cast ('2//1//e7' as integer); = 210000000
     select cast ('2:1' as integer);    = 21
     select cast ('2%1' as integer);    = 21
     select cast ('2,1' as integer);    = 21
     select cast ('2,,,1' as integer);  = 21
     select cast ('2,/:%1' as integer); = 21

but the following do not(they generate an invalid data message of some sort):

     select cast ('2x1' as integer);
     select cast ('2*1' as integer);

My guess is that since '/', ':', ',' & '%' are valid characters that can be used in a format clause for numeric data (refer to the manual); it appears that the cast is removing them for the purposes of doing a conversion from character to integer.

Whether this is appropriate or not is a whole 'nother question.


Hope this helps

Glenn Mc


P.S. My Test environment was V2R6.0



     
  <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: 27 Dec 2016