<p>I have this in some WSDL:</p>
<pre><code>&lt;element name=&quot;startDate&quot; type=&quot;xsd:dateTime&quot;/&gt;
&lt;element name=&quot;endDate&quot; type=&quot;xsd:dateTime&quot;/&gt;
</code></pre>
<p>Which results in the following text in the SOAP envelope:</p>
<pre><code>&lt;startDate&gt;2008-10-29T12:01:05&lt;/startDate&gt;
&lt;endDate&gt;2008-10-29T12:38:59.65625-04:00&lt;/endDate&gt;
</code></pre>
<p>Only some times have the milliseconds and zone offset. This causes me a headache because I'm trying to get a range of 37 minutes and 54 seconds in this example, but because of the offset I end up with 4 hours, 37 minutes, 54.65625 seconds. Is this some kind of rounding error in DateTime? How do I prevent this from happening?</p>

What are you using to generate the date?  If you are building this XML in your code rather than using some serializer (WCF or XmlSerializer) you could use System.Xml.XmlConvert to generate and interpret the date as follows:
To create the string to put in the XML:
```
```
DateTime startDate = DateTime.Now;
string startDateString = System.Xml.XmlConvert.ToString(startDate);
```
```
To get the date out of the XML:
```
```
DateTime startDateFromXml = System.Xml.XmlConvert.ToDateTime(startDateString);
```
```
If you start with two DateTime instances that differ by 37 minutes and 54 seconds before you push them into XML they will still differ by 37 minutes and 54 seconds after you pull them out of the XML.