title: Best way to parse DateTime to SQL server
body: <p>I was wondering what is the best way to parse a DateTime object to your SQL server. </p>
  
  <p>Where you are generating the SQL in code. </p>
  
  <p>I have always used something like <code>DateTime.Now.TolongDateString()</code> and had good results, apart from today where i got a error, and it made me think. </p>
  
  <pre><code>System.Data.SqlClient.SqlException: Conversion failed when converting datetime from character string
  </code></pre>
  
  <p>So what is everyone thoughts and recomendations for a way that will work acrss all SQL server no matter what there setup.. </p>
  
  <p>Maybe something like <code>DateTime.Now.ToString("yyyy/MM/dd")</code> </p>