title: totaling hours by month for split weeks using linq
body: <p>I am trying to total hours for an entire year by month.
  However, I have come accross an issue for months that end and start in the middle of the week.
  Here is my solution however, i had to hardcode the linq to work for this particular week date.
  In this example the</p>
  
  <pre><code> WeekStart is Febuary 26 2012 - SUNDAY
      WeekEnd is March 1 2012 - THURSDAY
  </code></pre>
  
  <p>Now in my hardcoded example
  when it is a normal week this is used (refer to sumval)</p>
  
  <pre><code>.ToUpper()).Sum(y =&gt; y.TOTALHOURS).Value;
  </code></pre>
  
  <p>when it is a split week for the next month it will use (refer to sumval1)</p>
  
  <pre><code>.ToUpper()).Sum(y =&gt; y.THURSDAY + y.FRIDAY + y.SATURDAY).Value;
  </code></pre>
  
  <p>when it is a split week for the previous month (refer to sumval2)</p>
  
  <pre><code>.ToUpper()).Sum(y =&gt; y.SUNDAY + y.MONDAY + y.TUESDAY + y.WEDNESDAY).Value;
  </code></pre>
  
  <p>Based on these the hours will be charged to the proper month on weeks that are split between twon months.</p>
  
  <p>problem is i dont want to hard code these days of the week, how can i dynamically populate the days that should be added for sumval1 and sumval2</p>
  
  <pre><code>  double sumval =    data.Where(x =&gt; 
      //ExportHelper.isSplitWeek(x.WKENDDATE, x.WKENDDATE.AddDays(6)) != true &amp;&amp;
      x.PORTFOLIO.ToUpper() == item.portfolio.ToUpper() &amp;&amp;
      x.PHASE.ToUpper() == portitem.phase.ToUpper() &amp;&amp; 
      x.PHASEDESCRIPTION.ToUpper() == portitem.phasedesc.ToUpper() &amp;&amp; 
      x.WKENDDATE.ToString("MMM yyyy").ToUpper() == monitem.monthname.ToString() 
     .ToUpper()).Sum(y =&gt; y.TOTALHOURS).Value;
  
  
    double sumval1 =
         data.Where(x =&gt;
         ExportHelper.isSplitWeek(x.WKENDDATE, x.WKENDDATE.AddDays(6)) == true &amp;&amp;
         x.PORTFOLIO.ToUpper() == item.portfolio.ToUpper() &amp;&amp;
         x.PHASE.ToUpper() == portitem.phase.ToUpper() &amp;&amp;
         x.PHASEDESCRIPTION.ToUpper() == portitem.phasedesc.ToUpper() &amp;&amp;
         ExportHelper.getSplitEndDate(x.WKENDDATE).AddDays(1).ToString("MMM yyyy").ToUpper() == monitem.monthname.ToString()
        .ToUpper()).Sum(y =&gt; y.THURSDAY + y.FRIDAY + y.SATURDAY).Value;
  
  
  
    double sumval2 =
        data.Where(x =&gt;
        ExportHelper.isSplitWeek(x.WKENDDATE, x.WKENDDATE.AddDays(6)) == true &amp;&amp;
        x.PORTFOLIO.ToUpper() == item.portfolio.ToUpper() &amp;&amp;
        x.PHASE.ToUpper() == portitem.phase.ToUpper() &amp;&amp;
        x.PHASEDESCRIPTION.ToUpper() == portitem.phasedesc.ToUpper() &amp;&amp;
        x.WKENDDATE.ToString("MMM yyyy").ToUpper() == monitem.monthname.ToString()
       .ToUpper()).Sum(y =&gt; y.SUNDAY + y.MONDAY + y.TUESDAY + y.WEDNESDAY).Value;
  </code></pre>