I need help with this Conversion failed when converting date and/or time from character string.
I'm trying to run a simple query on an @as_of_date, 10 days ago and 30 days ago. The query works fine if I run it on 3-5 accounts, but any more than that if fails. How do I change my query so that I don't get the conversion error?
Edit
Also tried removing the quotes from the select statement. Still doesn't work.


"@as_of_date"instead of value of variable with that name. remove quotes.mm-dd-yyyyinstead of a format that can't be misinterpreted by regional/language settings, likeyyyymmdd? Please read this in full. Also, show all of the code, as I don't believe the error is happening in the portion you've shown.CONVERT(date,'02-25-2015',110)toCONVERT(date,'2015-2-25',110). This one is correct format.@as_of_dateactually is of typedateso no conversion needed 2) you are hiding problematic part of query