You can check the length of the date string and convert it accordingly...
SELECT '8/12/2012' AS COL1
, CASE WHEN CHAR_LENGTH(COL1) = 9 THEN CAST('0'||COL1 AS DATE FORMAT 'DD-MM-YYYY')
ELSE CAST(COL1 AS DATE FORMAT 'DD-MM-YYYY')
END
↧