The following sql query works and receives 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 several days I have been trying to figure out how to do this with the Framework entity. So far my best approach is:
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, and not just by date. The result is this:
[0] = { DayOfMonth = {06.07.2009 12:38:59}, VisitsPerDay = 1 }
but it should look like
[0] = { DayOfMonth = {06.07.2009}, VisitsPerDay = 12 }
- How to change the date format used for grouping?
- How to filter only Days of the current month, as in an SQL query?
Frank meier
source
share