title: Insert datetime2 into database
body: <p>I am using <code>datetime2</code> as the datatype for <code>checkIn</code> and <code>checkOut</code>. Previously I can add into database with this code.</p>
  
  <pre><code>//value for checkIn = 12/25/2015 2:00:00 PM
  checkIn = DateTime.ParseExact(Session["checkInDate"].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture).AddHours(14);
  
  //value for checkOut = 12/26/2015 12:00:00 PM
  checkOut = DateTime.ParseExact(Session["checkOutDate"].ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture).AddHours(12);
  
  strInsert = "INSERT INTO Reservation ( checkInDate, checkOutDate) VALUES (@checkInDate, @checkOutDate)";
  
  cmdInsert = new SqlCommand(strInsert, conn);
  cmdInsert.Parameters.AddWithValue("@checkInDate", checkIn);
  cmdInsert.Parameters.AddWithValue("@checkOutDate", checkOut);
  </code></pre>
  
  <p>But now it doesn't work and I am getting this error;</p>
  
  <blockquote>
    <p>"Conversion failed when converting date and/or time from character
    string".</p>
  </blockquote>
  
  <p>I think the error is caused by the check in value which contain the "PM" and "AM", but it is weird because previously I am able to add this into the database. </p>
  
  <p>Does anybody know how to fix this?</p>