Cast and Convert Problem in SQL server 2000

  • Hi .. we are storing date as varchar(8) in database for some reasons. I want this field as Search Criteria and For that I am using Cast function to convert that into datetime format as Cast(Vdate as datetime) ..

    This works fine in my server. when we hosted the application on US server..This gives a following error message

    Arithematic Overflow...error in converting varchar to datetime ...

    I tried with Convert Function too ..but still problem persists.

    thanks

    VENU

    Venu


    Venu

  • MAKE sure the values you are saving are in the right order on the US server,

    I mean = mmddyyyy AND NOT ddmmyyyy

    an easy way to check will be to return rows where Cast(Left(field,2) as int) >12


    * Noel

  • If you are storing them as eight characters (should use char(8), not varchar(8), BTW), then are they something like '19/12/03' or something like '20031219'? The latter is the ISO standard and will work anywhere. The former is region-specific, won't sort correctly, and has two-digit years. You can, however, convert using:

    
    
    SELECT CONVERT(datetime,'19/12/03',3)

    --Jonathan



    --Jonathan

  • Hi ,

    It is solved. Special thanks to noeld.

    Have a nice day

    Venu


    Venu

Viewing 4 posts - 1 through 4 (of 4 total)

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