SELECT '8/12/2012' AS COL1
, CAST(CASE WHEN CHAR_LENGTH(SUBSTRING(COL1 FROM 1 FOR POSITION('/' IN COL1)-1))=1 THEN '0'||SUBSTRING(COL1 FROM 1 FOR POSITION('/' IN COL1)-1) ELSE SUBSTRING(COL1 FROM 1 FOR POSITION('/' IN COL1)-1) END || '/'
|| CASE WHEN CHAR_LENGTH(SUBSTRING(SUBSTRING(COL1 FROM POSITION('/' IN COL1)+1 FOR CHAR_LENGTH(COL1)-POSITION('/' IN COL1)) FROM 1 FOR POSITION('/' IN SUBSTRING(COL1 FROM POSITION('/' IN COL1)+1 FOR CHAR_LENGTH(COL1)-POSITION('/' IN COL1)))-1))=1 THEN '0'||SUBSTRING(SUBSTRING(COL1 FROM POSITION('/' IN COL1)+1 FOR CHAR_LENGTH(COL1)-POSITION('/' IN COL1)) FROM 1 FOR POSITION('/' IN SUBSTRING(COL1 FROM POSITION('/' IN COL1)+1 FOR CHAR_LENGTH(COL1)-POSITION('/' IN COL1)))-1) ELSE SUBSTRING(SUBSTRING(COL1 FROM POSITION('/' IN COL1)+1 FOR CHAR_LENGTH(COL1)-POSITION('/' IN COL1)) FROM 1 FOR POSITION('/' IN SUBSTRING(COL1 FROM POSITION('/' IN COL1)+1 FOR CHAR_LENGTH(COL1)-POSITION('/' IN COL1)))-1) END
|| '/' || SUBSTRING(SUBSTRING(COL1 FROM POSITION('/' IN COL1)+1 FOR CHAR_LENGTH(COL1)-POSITION('/' IN COL1)) FROM POSITION('/' IN SUBSTRING(COL1 FROM POSITION('/' IN COL1)+1 FOR CHAR_LENGTH(COL1)-POSITION('/' IN COL1)))+1 FOR CHAR_LENGTH(COL1)-POSITION('/' IN SUBSTRING(COL1 FROM POSITION('/' IN COL1)+1 FOR CHAR_LENGTH(COL1)-POSITION('/' IN COL1)))) AS DATE FORMAT 'DD-MM-YYYY')
↧