following sql query is working and gets the visits per day for the current month
select date(date) as DayDate, count(*) As visitsaday from Visits group by DayDate having DayDate between date('now','start of month') and date('now','start of month','+1 month','-1 day')
For days I try to figure out how to get this running with the entity Framework. My best aproach so far ist this:
ObjectQuery<Visit> visits = fitent.VisitMenge;
var uQuery =
from visit in visits
group visit by visit.Date into g
select new
{
DayOfMonth = g.Key,
VisitsPerDay = g.Count()
};
The Problem here is, that it will be grouped by Date + time instead of just the Date. An result is like:
[0] = { DayOfMonth = {06.07.2009 12:38:59}, VisitsPerDay = 1 }
but it should look like
[0] = { DayOfMonth = {06.07.2009}, VisitsPerDay = 12 }
- How can the Date Format changed which is used for grouping ?
- How to filter Just the Days of the current Month like in the SQL Query ?