Convert datetime

  • I am getting error for this:

    'CONVERT(datetime, '20101001', 112)', 'CONVERT(datetime, '20101231', 112)')

    Can someone please let me know what is wrong in this convert.

    Thank you

  • Use Following

    select CONVERT(datetime, '20101001', 112), CONVERT(datetime, '20101231', 112)

    Or For Dynamic

    exec ('select CONVERT(datetime, ''20101001'', 112), CONVERT(datetime, ''20101231'', 112)')

    Thanks

    Kuldeep

    Kuldeep Bisht
    Simplion Technologies
    http://mssqlguide.kuldeepbisht.com

  • bisht.kuldeep has it correct. you don't need the extra quotes in there, which cause a syntax error.

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

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