Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

CASE statement - response (2) by cheeli

$
0
0

Hi Dieter,
Can you please explain below (I encountered it in our code - generated through Informatica) -- colname is a varchar(24) unicode

 CAST(
 (
CASE	WHEN ((CHARACTER_LENGTH(tablename.colname) = 8) 
	AND	(tablename.colname  <> '00000000')) THEN
	 CAST(tablename.colname  AS TIMESTAMP FORMAT 'YYYYMMDD') 
ELSE	CAST('00010101' AS TIMESTAMP FORMAT 'YYYYMMDD') 
END	
) AS date)

Instead of casting the colname in both cases to timestamp and then to date, it can be done directly to date as below.

 
 CAST(
 (
CASE	WHEN ((CHARACTER_LENGTH(tablename.colname) = 8) 
	AND	(tablename.colname  <> '00000000')) THEN
	 tablename.colname   
ELSE	'00010101' 
END	
) AS date format 'YYYYMMDD')

Not sure, what caused them to follow the above one.  Is it due to Informatica
 


Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>