title: Inserting ISO date in sql server
body: <p>When I run the below code in c#</p>
  
  <pre><code>string dt = "2017-07-09T17:50:21.000-0500"; 
  string date = DateTimeOffset.Parse(dt).DateTime.ToString("yyyy-MM-dd HH:mm");
  </code></pre>
  
  <p>it gives this as output</p>
  
  <blockquote>
    <p>2017-07-09 17:50</p>
  </blockquote>
  
  <p>but on inserting the same to database it is adding +5 hrs to the time and inserting as </p>
  
  <blockquote>
    <p>2017-07-09 22:50 </p>
  </blockquote>
  
  <p>could someone please help me to insert the same date (2017-07-09 17:50) to database</p>
  
  <hr>
  
  <p><strong>Update 1</strong></p>
  
  <p>Here is my complete simplified code</p>
  
  <pre><code>DataSet dSet = new DataSet();
  DataTable dTable = new DataTable();
  dTable.Columns.Add("created_on", typeof(DateTime));
  
  foreach (var item in items)
  {
  DataRow dRow = dTable.NewRow();
  dRow["created_on"] = DateTimeOffset.Parse(item.createdon).DateTime;
  //-- in item.createdon i get the date like this "2017-07-09T17:50:21.000-0500";
  dSet.Tables[0].Rows.Add(dRow);
  }
  </code></pre>
  
  <p>after completing the loop,sending the data to database as xml via stored procedure to insert.</p>
  
  <p>After inserting in database the row is updated with the below date</p>
  
  <blockquote>
    <blockquote>
      <p>2017-07-09 22:50</p>
    </blockquote>
  </blockquote>