Wrestling with DateTime data from SQL Sever 2000/2005 DB

  • Hey guys. I tried to work out the solution myself before asking for help but couldn't get this to work. So here I am.

    I have a old SQL 2005 or even 2000 table I'm pulling from and inserting into a table in a SQL 2012 DB. One field in particular is giving me a lot of grief. The data types are in fact both DateTime in the source table and the destination table. Yet, I still get the error:

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

    The source data is formatted like this:

    2004-03-25 11:35:11.000

    2004-05-18 15:06:29.000

    ...and I've tried:

    CONVERT(DateTime2,[OldTable].[OldField], 121) As X

    CONVERT(DateTime,[OldTable].[OldField], 121) As X

    and have been referring to this page:

    http://msdn.microsoft.com/en-us/library/ms187928.aspx

    No luck.

    Any thoughts?

  • Resolved. Thanks

  • RedBirdOBX (11/5/2013)


    Resolved. Thanks

    Please post your resolution so that others might benefit. Thanks.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply