title: Calculate Max and Min Dates with LINQ2XML
body: <p>maybe a litte issue, but I don't understand what's running wrong here. </p>
  
  <p>The code below is targeting an XML File (sample also below) and trys to calculate the absolute Min Date and absolute Max Date from all the same events over all Descendants of the Element 'eventBlocks'. (earliest/latest Date of all 'EventC' elements, ...)</p>
  
  <p>As you can see one of the enddates for 'ElementC' (for eaxample) has an endDate '1/14/2011'. This should be my MaxDateTo value. But the result shows a calculated maxEndDate of '1/6/2011'and ignores the right value.</p>
  
  <p>I asume that the comparer takes it as string or int and provides a wrong result. </p>
  
  <p>What (and how) have I to do to get the correct Max and Min Dates calculated? </p>
  
  <p>Thanks in advance
  Marcus</p>
  
  <pre><code> var xmlDoc = XDocument.Load(@"c:\Temp\MergedCalendar2011.xml");
  
      var result = from vb in xmlDoc.Descendants("eventBlock")
                   group vb by vb.Attribute("eventName").Value into blocks
                   orderby blocks.Key ascending
                   select new
                   {
                       BlockName = blocks.Key,
                       MinDateFrom = blocks.Min(min =&gt; min.Attribute("start").Value),
                       MaxDateTo = blocks.Max(max =&gt; max.Attribute("end").Value),
                   };
  </code></pre>
  
  <p>This is the XML:</p>
  
  <pre><code>&lt;?xml version="1.0" standalone="yes"?&gt;
  &lt;year year="2011" id="year2011"&gt;  
    &lt;state name="Baden Wuerttemberg" &gt;
      &lt;eventBlocks&gt;
        &lt;eventBlock eventName="EventX" start="4/21/2011" end="4/22/2011" /&gt;
        &lt;eventBlock eventName="EventX" start="4/26/2011" end="5/1/2011" /&gt;
        &lt;eventBlock eventName="EventZ" start="6/14/2011" end="6/26/2011" /&gt;
        &lt;eventBlock eventName="EventA" start="7/28/2011" end="9/11/2011" /&gt;
        &lt;eventBlock eventName="EventB" start="10/31/2011" end="11/1/2011" /&gt;
        &lt;eventBlock eventName="EventB" start="11/2/2011" end="11/5/2011" /&gt;
        &lt;eventBlock eventName="EventC" start="1/1/2011" end="1/14/2011" /&gt;
        &lt;eventBlock eventName="EventC" start="12/23/2011" end="1/14/2012" /&gt;
      &lt;/eventBlocks&gt;
    &lt;/state&gt;
      &lt;state name="Brandenburg" &gt;   
      &lt;eventBlocks&gt;
        &lt;eventBlock eventName="EventY" start="1/31/2011" end="2/6/2011" /&gt;
        &lt;eventBlock eventName="EventX" start="4/20/2011" end="5/1/2011" /&gt;
        &lt;eventBlock eventName="EventZ" start="6/3/2011" end="6/4/2011" /&gt;
        &lt;eventBlock eventName="EventA" start="6/30/2011" end="8/14/2011" /&gt;
        &lt;eventBlock eventName="EventB" start="10/4/2011" end="10/15/2011" /&gt;
        &lt;eventBlock eventName="EventC" start="1/1/2011" end="1/2/2011" /&gt;
        &lt;eventBlock eventName="EventC" start="12/23/2011" end="1/1/2012" /&gt;
      &lt;/eventBlocks&gt;
    &lt;/state&gt;
    &lt;state name="Bremen"&gt;   
      &lt;eventBlocks&gt;
        &lt;eventBlock eventName="EventY" start="1/31/2011" end="2/2/2011" /&gt;
        &lt;eventBlock eventName="EventX" start="4/16/2011" end="5/1/2011" /&gt;
        &lt;eventBlock eventName="EventZ" start="6/3/2011" end="6/4/2011" /&gt;
        &lt;eventBlock eventName="EventZ" start="6/14/2011" end="6/15/2011" /&gt;
        &lt;eventBlock eventName="EventA" start="7/7/2011" end="8/18/2011" /&gt;
        &lt;eventBlock eventName="EventB" start="10/17/2011" end="10/30/2011" /&gt;
        &lt;eventBlock eventName="EventC" start="1/1/2011" end="1/6/2011" /&gt;
        &lt;eventBlock eventName="EventC" start="12/23/2011" end="1/1/2012" /&gt;
      &lt;/eventBlocks&gt;
    &lt;/state&gt;
    &lt;/year&gt;
  </code></pre>