title: Current date slips back to yesterday when sent as Xml to Sql Server
body: <p>I'm sending data from a winforms project to a Sql Server database by turning the object data into XML and then parsing it on the SQL side out to the target tables.</p>
  <p>This works fine, except for an issue with dates.</p>
  <p>Often I am not interested in the time part of a datetime value, just the date, so have dates basically entered in the front end as '2021-08-05 00:00:00'.</p>
  <p>When I create the XML, it becomes:</p>
  <p>2021-08-05T00:00:00+01:00</p>
  <p>(+01:00 because I am in the UK, and we are currently an hour ahead of UTC/GMT).</p>
  <p>But when that ends up in the Date field in the relevant table, the value has slipped back to 2021-08-04, i.e. yesterday.</p>
  <p>Is there a way to control how the XML is generated to stop it adding the time zone difference?</p>
  <p>The classes for the data objects are all tagged with <code>[Serializable]</code> at the top. I don't have any special attributes on the date properties themselves.</p>
  <p>This is the c# code that converts the object into XML, though I don't think there is a problem here per se (and I probably nicked it from some helpful post up here anyway!):</p>
  <pre><code>public static string ConvertToXmlDoc(object dataModeldata)
  {
     Type modelType = dataModeldata.GetType();
     var writer = new XmlSerializer(modelType);
     StringWriter sw = new StringWriter();
     writer.Serialize(sw, dataModeldata);
     string xmlDoc = sw.ToString();
     return xmlDoc;
  }
  </code></pre>