0

I am trying to query data with in the last 7 days using Firebase Firestore, I have a stored the date as a field in the document but i dont know how to create a query where it only adds data from the last 7 days.

db.collection("dataToSave").whereEqualTo("Email", mAuth.getCurrentUser().getEmail())
    .get()
    .addOnCompleteListener(new OnCompleteListener < QuerySnapshot > () {
        @Override
        public void onComplete(@NonNull Task < QuerySnapshot > task) {
            if (task.isSuccessful()) {
                for (QueryDocumentSnapshot document: task.getResult()) {

                    Log.d(TAG, document.getId() + " => " + document.get("Date").toString() + document.get("Status"));
                    thisWeeksClockings.add(document.get("Date").toString() + (" ") + document.get("Status"));

                    //                            Toast.makeText(getApplicationContext(),document.getData().toString() ,Toast.LENGTH_LONG).show();
                }
            } else {
                Log.w(TAG, "Error getting documents.", task.getException());
            }

            adapter = new MyRecyclerViewAdapter(thisWeeksClockings);
            recyclerView.setAdapter(adapter);

        }
    });
}
Ermiya Eskandary
  • 15,323
  • 3
  • 31
  • 44

0 Answers0