title: Cannot pass date into stored procedure
body: <p>Trying to pass date into a stored procedure as follows:</p>
  
  <pre><code>@dateRegistered = '28/04/2012'
  </code></pre>
  
  <p>But it keeps telling me:</p>
  
  <blockquote>
    <p>Error converting data type varchar to date.</p>
  </blockquote>
  
  <p>It works if I do it as:</p>
  
  <pre><code>@dateRegistered = '04/28/2012'
  </code></pre>
  
  <p>But this is not the format I want to use.</p>
  
  <p>I have run the following query to set the format:</p>
  
  <pre><code>SET DATEFORMAT dmy
  </code></pre>
  
  <p>Why isn't it working?</p>
  
  <p>Edit: Here is how I did it:</p>
  
  <p>In my stored procedure, I put:</p>
  
  <pre><code>SET DATEFORMAT dmy
  </code></pre>
  
  <p>Then from code, I pass it as:</p>
  
  <pre><code>myCommand.Parameters.Add("@dateRegistered", SqlDbType.Date);
  myCommand.Parameters["@dateRegistered"].Value = DateTime.Now.ToString("dd/mm/yyyy");
  </code></pre>
  
  <p>I passed it as string to ensure that even if my computer (or the server) has a different date format, it will always use dmy.</p>
  
  <p>Edit Edit:</p>
  
  <p>I passed it as datetime.now. It seems to transform it to the default format when I send it, and then transform it back to my computer format when I read it. Unsure how exactly this happens, but it seems to be working fine.</p>