title: Datetime issue with stored procedure in SQL Server
body: <p>The following code doesn't appear to run when executed by code:</p>
  
  <p>Stored procedure snippet:</p>
  
  <p><a href="http://codeviewer.org/view/code:2371" rel="nofollow">Click to view full SP</a></p>
  
  <pre><code> AND (@month_ref = 81201 
        AND tsks.grouping_ref = @grouping_ref 
        AND ts.start_dtm BETWEEN convert(datetime, '2011-11-28') 
                             AND convert(datetime,'2012-01-01')
       )
    OR (@month_ref = 81202 
        AND tsks.grouping_ref = @grouping_ref 
        AND ts.start_dtm BETWEEN convert(datetime,'2012-01-02') 
                             AND convert(datetime,'2012-01-29')
       )...
  </code></pre>
  
  <p>Server setup:</p>
  
  <p>SQL Server is setup as:</p>
  
  <ul>
  <li>Language: English (United States)</li>
  </ul>
  
  <p>And Windows Server region and language are set to:</p>
  
  <ul>
  <li>English (United States)</li>
  </ul>
  
  <p>Our test server is set up for British English and the stored procedure appears to work just fine. I have a feeling the customer setup doesn't like the dates.</p>
  
  <p>DB design / data</p>
  
  <p><code>ts.start_dtm</code> looks like this in the database:</p>
  
  <ul>
  <li><p>datatype - datetime</p>
  
  <pre><code>2011-04-01 00:00:00.000
  </code></pre></li>
  </ul>
  
  <p>So its setup as - <code>YEAR | MONTH | DATE</code></p>
  
  <p>My stored procedure is hardcoding the <code>start_dtm</code> as <code>'2012-01-02'</code> which is also in the same format.</p>
  
  <p>Can you help me please?</p>
  
  <p>The problem is the website fails when it tries to run the stored Procedure. The issue was the data conversion. I had to assign the format of date conversion.</p>