Home Forums SQL Server 2005 T-SQL (SS2K5) Conversion failed when converting datetime from character string. RE: Conversion failed when converting datetime from character string.

  • yes, I use cast in the innermost query then use datepart in the outer part to get the year and month. If I try to filter by the date, the year or the month in the where clause I get this error.

    I actually use this query to create a view and when looking at the view the columns are datetime for the importdate and int for the year and month. I can also select from the view with no problem. Also when I use ISDATE(importdate) on the view it comes back successful. The only time I get an error is when I try to do a WHERE importyear = 2007 or WHERE importmonth = 10

    I'm sure there must be an easy explanation here, but I just cant see it.

    Best regards

    Susan