SQL 7 To 2000: CONVERT errors

  • I am getting

    Error Msg 241

    Cannot convert datetime to a character string.

    DECLARE RUNDATE DATETIME

    SET @RUNDATE = '31/05/2005'

    SELECT @RUNDATE

    I am using a new build of SQL 2000 and I don't think our settings are correct.

    Although the language is set to English, it was also set to English on our old SQL 7 Server, but it does not get the error???

    It seems to implicitly set the Date format to mdy.  Any ideas. At the prototype stage so can change most settings - don't want to change the TSQL though.

     

     

     

  • First, your declare is wrong. You forgot "@" for variable.

    DECLARE RUNDATE DATETIME -> DECLARE @RUNDATE DATETIME

    Second, what is the dateformat that you want? Yours look like [dd/mm/yyyy]. American standard is [mm/dd/yyyy] as you know. If you want to keep the dateformat, here is the script that you can try.

    -- Start --

    SET DATEFORMAT dmy

    DECLARE @RUNDATE DATETIME

    SET @RUNDATE = '31/05/2005'

    SELECT @RUNDATE

    -- End --

     

     

     

     

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

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