Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Converting date field defined as char(8) to date bypassing invalid values

$
0
0

I'm converting a date field to date using date fields defined as char(8) with some values that are invalid such as "011 1212".

With this code: "min(convert(date, F6))"

I'm getting this error message:

Conversion failed when converting date and/or time from character string

With this code: "min(convert(date, isdate(F6))"

I'm getting this error message:

Explicit conversion from data type int to date is not allowed.

I'm trying to bypass all the fields that have invalid dates so it will not error out.

But it seems like the isdate function is not filtering the invalid values.

Thank you very much for the help.

Note:
There is no option to update the field definition since this is production. I have to work with what I currently have in the system.

Viewing all articles
Browse latest Browse all 23857

Trending Articles