• rVadim (8/16/2012)


    Instead of 103 use 03

    DECLARE @D CHAR(10) = '17/08/12'

    SELECT CONVERT(date, @D, 03)

    03? That is old ambulance number in Russia, you can use just 3 ...:hehe:

    Actually, SQL can convert '17/08/12' and '17/08/2012' into date without help of the third (dateformat) parameter. You are facing the issue due to the default format on your server is in American style (mm/dd/yyy). You can easily change it any time to whatever you like. The following example will explain it to you in a more visual way:

    SET DATEFORMAT DMY

    DECLARE @D CHAR(10) = '17/08/12'

    SELECT CONVERT(date, @D)

    SET @D = '17/08/2012'

    SELECT CONVERT(date, @D)

    GO

    SET DATEFORMAT MDY

    DECLARE @D CHAR(10) = '8/17/12'

    SELECT CONVERT(date, @D)

    SET @D = '08/17/2012'

    SELECT CONVERT(date, @D)

    GO

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]