1

I have a database that already has a lot of data in it and we need to be able to pull entries based on the dates they were added. Is there a way to pull only the entries that were added between for instance January 1, 2018 and January 7, 2018?

Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
Andoo80
  • 27
  • 6

1 Answers1

1

Yes you can use this query:

DatabaseReference ref=FirebaseDatabase.getInstance().getReference().child("times");
ref.orderByChild("date").startAt("2018-01-01").endAt("2018-01-07");

example if you have this:

times
  pushid
   date:2018-01-01
  pushid
   date: 2018-01-07
Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
  • This did work, but our queries are still running very slowly. Is there a way to speed up the query itself? Or sort through the data quicker? – Andoo80 Apr 02 '18 at 21:36
  • maybe optimize the database more https://stackoverflow.com/questions/39768084/querying-on-firebase-database-with-large-data-set-is-very-very-slow, or ask it as a question with more information provided – Peter Haddad Apr 02 '18 at 21:39