I have a problem converting a SQL Column (date_column) to 104 date format. In the date column are two different types of dates. One is in dd-mm-yyyy format and the other one is a consecutive number format (39448). I wrote this query to convert the date into 104 date format (yyyy-mm-dd), but it didn't work.
SELECT date_column
CASE WHEN [date_column] like '%-%'
THEN try_convert(date,date_column,104)
ELSE convert(date,cast(date_column - 2 as smalldatetime),104)
END
FROM xyz;
Error: Conversion failed when converting the nvarchar value '08-09-2017' to data type int.