2
I am running a query in a view, but one of its fields is text, in this field the user can inform a date (xx/xx/xxxx) as well as any other information of type text. I wonder how I can return only the records I can convert to date or how I can treat the error below, which occurs when I try to convert the field into the type I need?
Error: Conversion failed when Converting date and/or time from Character string.
consultation I’m doing:
SELECT
V.CAMPO1,
V.CAMPO1,
V.CAMPO1,
V.CAMPO_CHAR_DATA,
CASE WHEN RTRIM(V.CAMPO_CHAR_DATA) <> '' THEN
CONVERT(DATETIME, RTRIM(V.CAMPO_CHAR_DATA, ),103)
ELSE '2017-01-01 00:00:00'
END AS CAMPO_CHAR_DATA
FROM VIEW_TESTE V
Renan, thanks for the answer! It worked! o/
– Fabio Sousa