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

Timestamp format on teradata retrieval - response (8) by kashifkiani

$
0
0
From 12/8/2010 8:00:40 PM  8/30/2011 5:10:35 PM  To 12/08/2010 20:00:40 08/30/2011 17:10:35   Suppose datetime column is start_date Query   CAST( CAST( CAST( CASE WHEN INDEX(START_DATE,' ')=0 THEN NULL ELSE CASE WHEN SUBSTRING(START_DATE FROM 1 , INDEX(START_DATE,'/')-1 )>9 THEN SUBSTRING(START_DATE FROM 1 , INDEX(START_DATE,'/')-1 ) ELSE '0'||SUBSTRING(START_DATE FROM 1 , INDEX(START_DATE,'/')-1 ) END ||'/'|| CASE WHEN SUBSTRING(START_DATE FROM INDEX(START_DATE,'/')+1 , INDEX(SUBSTRING(START_DATE FROM INDEX(START_DATE,'/')+1),'/')-1 )>9 THEN SUBSTRING(START_DATE FROM INDEX(START_DATE,'/')+1 , INDEX(SUBSTRING(START_DATE FROM INDEX(START_DATE,'/')+1),'/')-1 ) ELSE '0'||SUBSTRING(START_DATE FROM INDEX(START_DATE,'/')+1 , INDEX(SUBSTRING(START_DATE FROM INDEX(START_DATE,'/')+1),'/')-1 ) END ||'/'|| SUBSTRING (SUBSTRING(START_DATE FROM INDEX(START_DATE,'/')+1) FROM INDEX(SUBSTRING(START_DATE FROM INDEX(START_DATE,'/')+1),'/')+1,4) ||' '|| CASE WHEN SUBSTRING( SUBSTRING(START_DATE FROM INDEX(START_DATE ,' ')+1) FROM 1, INDEX(SUBSTRING(START_DATE FROM INDEX(START_DATE ,' ')+1),':')-1 )>9 THEN SUBSTRING( SUBSTRING(START_DATE FROM INDEX(START_DATE ,' ')+1) FROM 1) ELSE '0'||SUBSTRING( SUBSTRING(START_DATE FROM INDEX(START_DATE ,' ')+1) FROM 1) END END AS TIMESTAMP(0) FORMAT 'mm/dd/yyyybhh:mi:ssbt') AS TIMESTAMP(0) FORMAT 'mm/dd/yyyybhh:mi:ss') AS VARCHAR(23))

Viewing all articles
Browse latest Browse all 27759

Trending Articles



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