title: Conversion failed when converting date and/or time from character string
body: <p>I have a query in SQL Server 2008.</p>
  
  <pre><code>SELECT
      CONVERT(char(80), i.InvDate,3) AS InvDate,
      i.InvoiceNo,
      i.TaxAmount + i.SubTotal AS Amount,
      '' AS Payment,
      pd.GivenName
  FROM
  dbo.Invoice i
      INNER JOIN dbo.PatientDetails pd ON (pd.MedicalRecordID = i.MedicalRecordID)
      WHERE (InvDate &gt;= CONVERT(datetime, '16/10/2012', 105)) AND 
  (InvDate &lt;= CONVERT(datetime, '16/10/2012', 105))
  </code></pre>
  
  <hr>
  
  <p>Output:</p>
  
  <p><a href="https://i.stack.imgur.com/IWe0Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IWe0Y.png" alt="enter image description here"></a>
  </p>
  
  <p>When i tried to put that into C#, it says "Conversion failed when converting date and/or time from character string." </p>
  
  <hr>
  
  <p>Info: 16/10/2012 are sample dates which i tried to insert into the query to make sure it runs. It's a old program, thats why its converting from a string. I'm pretty sure its something gotta do with the datetime format.  Had a look at <a href="http://www.sqlusa.com/bestpractices/datetimeconversion/" rel="nofollow noreferrer">http://www.sqlusa.com/bestpractices/datetimeconversion/</a>. But i cant put a finger through it.</p>
  
  <pre><code>SqlCommand objCmd = new SqlCommand("SELECT CONVERT(char(80), i.InvDate,3) 
  
  AS InvDate,
  
  i.InvoiceNo, i.TaxAmount + i.SubTotal AS Amount,'' AS Payment,pd.GivenName 
  
  FROM
  
  dbo.Invoice i INNER JOIN dbo.PatientDetails pd
  
  ON 
  (pd.MedicalRecordID = i.MedicalRecordID)
  
  WHERE
  
  (InvDate &gt;= CONVERT(datetime, 'dd/MM/yyyy', 105)) 
  
  AND 
  
  (InvDate &lt;= CONVERT(datetime, 'dd/MM/yyyy', 105))", objConn);
  
  
  
          SqlDataReader objReader;
          objReader = objCmd.ExecuteReader();
  
          System.IO.FileStream fs = new System.IO.FileStream("C:\\CMSExportedData\\Sales-" + 
  DateTime.Now.ToString("dd-MM-yyyy") + ".txt", System.IO.FileMode.Create);
          System.IO.StreamWriter sw = new System.IO.StreamWriter(fs,   
  System.Text.Encoding.Default);
  </code></pre>