Syntax error converting datetime from character string

  • Hi All,

    SELECT dbkey, dbstatus, desc1, CONVERT(datetime, CONVERT(varchar, ISNULL(desc2, '31/12/9999')), 103) FROM ix_spc_planogram

    WHERE dbstatus in(1, 2, 101)

    While executing the above querty i am getting the below error:-

    Server: Msg 241, Level 16, State 1, Line 1

    Syntax error converting datetime from character string.

    i would be greteful if you could please let me know your suggestions on this?

    Many Thanks,

    Madhu

  • Use an ISO date format for your default maximum date.

    Assuming the desc2 field is a character string that contains a date/time that can be reliably and consistently converted to a datetime data type, then the following expression will work:

    CONVERT(datetime, ISNULL(desc2, '99991231'))

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

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