The kingdom does not yet support GroupBy. Also keep in mind that beginGroup () actually matches parentheses. Thus, your request is actually interpreted as:
// SQL pseudo code SELECT * FROM Account WHERE (date = MONTH(date))
In Realm, you need to do something like this to select one month:
// Between is [ monthStart, monthEnd ] Date monthStart = new GregorianCalendar(2015, 5, 1).getTime(); Date monthEnd = new GregorianCalendar(2015, 6, 1).getTime() - 1; accounts = realm.where(Account.class).between("date", monthStart, monthEnd).findAll();
or something like this to determine when a month changes
// pseudo code. You might want to use Calendar instead accounts = realm.where(Account.class).findAllSorted("date") Iterator<Account> it = accounts.iterator(); int previousMonth = it.next().getDate().getMonth(); while (it.hasNext) { int month = it.next().getDate().getMonth(); if (month != previousMonth) { // month changed } previousMonth = month; }
source share