title: How to overcome the error: Conversion failed when converting date and/or time from character string?
body: <p>I have a table with column DateList: varchar(4000). There is a list of dates as strings written in Russian. It looks as following:</p>
  
  <pre><code>2014-09-26 19:00 2014-09-27 19:00 2014-09-28 19:00 2014-09-29 19:00 2014-09-30 19:00
  </code></pre>
  
  <p>I also have stored procedure that reads DateList and should do something with it. But, the error "Conversion failed when converting date and/or time from character string" comes up. When I update DateList column with the same dates written in English, everything works fine. But, these dates were usually entered in Russian.</p>
  
  <p>I'm not sure if I have to use "nvarchar" instead of "varchar" in the table or there is another way to overcome this issue?</p>
  
  <p>The stored procedure:</p>
  
  <pre><code>ALTER PROCEDURE [FilterDates] (@sString NVARCHAR(4000), @MINDate DATETIME, @MaxDate DATETIME)
  AS
  BEGIN
      DECLARE @SplitChar NCHAR(1)
      DECLARE @Count INT
      DECLARE @DateLength INT 
      DECLARE @XMLString XML
  
      SET @SplitChar = ','
      SET @Count = 1      
      SET @DateLength = 17
      SET @sString = RTRIM(@sString) + ' '
  
     WHILE @Count &lt;= Len(@sString) / 17 - 1
      BEGIN
         SET @sString = STUFF(@sString, @DateLength, 0, ',')
  
         SET @DateLength = 17 + @DateLength + 1
         SET @Count = @Count + 1
      END
  
     --Use XML to extract the Date.
     SET @XMLString = CONVERT(xml,'&lt;root&gt;&lt;s&gt;' + REPLACE(@sString, @SplitChar, '&lt;/s&gt;&lt;s&gt;') + '&lt;/s&gt;&lt;/root&gt;')
  
     CREATE TABLE #Temp (DateVal NVARCHAR(4000))
  
     INSERT INTO #Temp (DateVal)
   SELECT DateValue 
   FROM (SELECT T.c.value('.', 'NVARCHAR(MAX)') AS DateValue FROM @XMLString.nodes('/root/s') T(c)) AS Temp  
   WHERE DateValue BETWEEN @MINDate AND @MaxDate
  
   SELECT LTRIM((SELECT DateVal AS DateVal FROM #Temp FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)')) AS ExpectedResult
  END
  </code></pre>
  
  <p>Here's how I call the stored procedure:</p>
  
  <pre><code>declare @sString NVARCHAR(4000)
  declare @MINDate DATETIME
  declare @MaxDate DATETIME
  SELECT @sString = DateList from T_Action where ID = 46591
  SET @MINDate = '2014-09-27'
  SET @MaxDate = '2014-09-30'
  EXEC FilterDates @sString, @MINDate, @MaxDate
  </code></pre>