• Sounds like a data problem - you'll have to find the problems in your data first, and then decide how to deal with them.

    Suggestions

    1) Run your script without the 'cast to datetime' i.e. keeping the result as a varchar. Then examine your results, and look for the one(s) that doesn't look right.

    2) Have you any nulls in either field?

    3) check the len(x) of the fields and look for misfits.

    Once you've found the problem data, then you need to judge whether it's enough to correct it, or whether more such data can find it's way in to the DB, in which case you'll have to 'handle it' more gracefully.