I have a desire to convert a column called recall_date to varchar yyyymmdd, which currently is formatted yymmdd.
The recall_date column has plenty of null values so we want to filter those out. When I run the below script I receive the error:
Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type datetime.
The statement has been terminated.
I realize that my 103 is a datetime convert - but I can go from datetime to yyyymmdd which is why I did that. There is likely an easier way.
set recall_date =
case when recall_date is not null
and len(recall_date) = 6
then CONVERT(varchar, CAST(recall_date AS DATETIME), 103)
else '' end