Linq Select row Where date in Current month
<p>I need to get data from the current month.Haven't been able to find a solution that works.</p>

<p>This is my code, which gives me the data I need, but I get data from a whole month back, instead of from the current month we are in.</p>

<p>I chose the date "limit" twice with <code>row &gt; DateTime.Today.Addmonths(-1)</code></p>

<p>Any ideas ?</p>

<pre><code>var userQuery = 
from timeEntry in TimeEntries
                                //this displays a month back, not current month TODO: change to current month.
where timeEntry.DateEntity &gt; DateTime.Today.AddMonths(-1)
select new {
    UserName = timeEntry.User.FirstName + " " +timeEntry.User.LastName,
    HoursEntered = timeEntry.HoursEntered,       
    User = timeEntry.User
};

var localrows = userQuery.ToList();

var grouping = localrows.GroupBy(x =&gt; x.User);

var userList = grouping.Select(q =&gt; new {
    UserName = q.FirstOrDefault().UserName,
    Hours = q.Sum(hr =&gt; hr.HoursEntered),                 //AbsenceTypeID = holiday(1)                          // still takes from a whole month, instead of current month.
    Holiday = q.FirstOrDefault().User.Absences.Where(a =&gt; a.AbsenceTypeID == 1).Where(date =&gt; date.DateEntity &gt; DateTime.Today.AddMonths(-1)).Count(),
});
</code></pre>

<p>EDIT:</p>

<p>Keyur patel' answer worked, though not for the bottom one.</p>

<p>so there i have to thank Jules for this one:</p>

<pre><code>DateTime.Today.AddDays((DateTime.Today.Day -1) * -1)
</code></pre>