Quantcast
Viewing all articles
Browse latest Browse all 16

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

The following query returns an error "Conversion failed when converting date and/or time from character string". However, if I changed "else v.value" to "else null" or remove the else, it worked fine. Why the else caused error on when? What is the work around?  

Thanks.

select v.name, v.value, 
case
	when isdate(v.value) = 1 and v.value is not null and rtrim(ltrim(v.value)) <> '' then cast(v.value))
	else v.value 
end
from tickets t join vVariablesForTickets v on v.process_id = t.process_id



Viewing all articles
Browse latest Browse all 16

Trending Articles