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

convert string to date format - response (14) by Harpreet Singh

$
0
0

Use as below 

SELECT 'Apr 3, 2013 8:28 PM' AS COL1     , case when position( ',' in (substring(COL1 FROM POSITION('' IN COL1)+1 for 3) )) =2 then 
SUBSTRING(COL1 FROM 1 FOR POSITION('' IN COL1)-1)||' 0'|| SUBSTRING(COL1 FROM POSITION('' IN COL1)+1) else COL1 end as datecorect,
substring(datecorect FROM POSITION(':' IN datecorect)-4) ,substring(datecorect FROM POSITION(':' IN datecorect)-3) ,substring(datecorect FROM  1 for POSITION(':' IN datecorect)-3) ,
case when position( '' in (substring(datecorect FROM POSITION(':' IN datecorect)-3) )) =2 then 
SUBSTRING(datecorect FROM 1 FOR POSITION(':' IN datecorect)-3)||' 0'|| SUBSTRING(datecorect FROM POSITION(':' IN datecorect)-1) else datecorect end as timecorect
,timecorect (timestamp, format 'MMMBDDBBYYYYBHH:MIBT')

 


Viewing all articles
Browse latest Browse all 27759

Trending Articles



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