title: Insert, select and update DateTime
body: <p>I have a table with time the column named time and the datatype is <code>Date</code>.</p>
  
  <p>In asp.net I want a query to insert the date, and another so select between 2 date.</p>
  
  <p>I already try this:</p>
  
  <pre><code>string data = DateTime.Now.ToShortDateString(); //date= 28/10/2014 -&gt; dd/mm/yyyy
  string comando = "INSERT INTO example (date) values '" +data+ "+"'";
  </code></pre>
  
  <p>And I used that query to select between 2 dates</p>
  
  <pre><code>select * 
  from example 
  where date &gt;= '25/10/2014' and date &lt;= '28/10/2014'
  </code></pre>
  
  <p>I already tried with datatype <code>varchar</code> but it doesn't work. So I'm trying with the datatype <code>date</code>.</p>
  
  <p>But when I'm executing the query <code>INSERT</code> I get a error </p>
  
  <blockquote>
    <p>Conversion failed when converting date and/or time from character string.</p>
  </blockquote>
  
  <p>Somebody please can help me? The only problem I have is to save the time into the table. </p>
  
  <p>If possible I want that format of the date: <code>dd/mm/yyyy</code></p>
  
  <p><strong>Update:</strong></p>
  
  <p>I'm having problem with update a row that have a date(date) and a varchar(name)
  That is my code:</p>
  
  <pre><code>string comando = "UPDATE example set name=@name WHERE data = @date";
  SqlCommand cmd = new SqlCommand(comando, connect);
  cmd.Parameters.Add("@name", nome);
  cmd.Parameters.Add("@date", SqlDbType.Date).Value = data;
  cmd.ExecuteNonQuery();
  </code></pre>
  
  <p>The messange error is: "String or binary data would be truncated.
  The statement has been terminated."</p>