• Michael Valentine Jones (10/27/2010)


    Toreador (10/27/2010)


    Hugo Kornelis (10/27/2010)


    print 'Format mdy'

    set dateformat mdy

    select x1 =convert(datetime,'2010-12-31')

    go

    print 'Format ymd'

    set dateformat ydm

    select x2=convert(datetime,'2010-12-31')

    Results:

    Format mdy

    x1

    ------------------------

    2010-12-31 00:00:00.000

    (1 row(s) affected)

    Format ymd

    Server: Msg 242, Level 16, State 3, Line 3

    The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

    Hugo,

    What if the client application is submitting the data as XML and thier regional setting is English (Cannada) or some other setting not the same as the SQL server? Wouldn't that also change the code needed to safely convert the string to a valid DateTime data type?