in reply to SQL Server CAST problem using CASE with DBD::ODBC

To track down a cast error, you need to find where the type conversion is being done and where the invalid data is coming from. Conversion errors happen freqently when passing data from Perl, especially when Perl chooses the wrong type to send to the database. Unless there is more code that you aren't showing us, the code isn't passing parameters and this is not the problem.

Since this is a static query, that Query Analyzer and Perl have different results is surprising. Try rewriting the SQL to eliminate the CASE, or use the other form of the CASE. CASE ... END AS is_complete is the same and might cause problems. Also, you might want to parse the date in Perl.