1

I'm trying to get the user to pick a date and then on click of a button will display all the content from Firestore related to that data.

Here mDisplayDate is a DatePicker Dialog and I want to display the data. I've done the display part but whereEqualTo() takes two hard coded strings as field and value.

noteBookref.whereEqualTo("Date" , mDisplayDate.toString()).orderBy("Date", Query.Direction.DESCENDING).get(); 

The Database looks like this

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
Palash Jain
  • 33
  • 1
  • 4
  • And what's the question? Please also add your database structure. – Alex Mamo Feb 17 '19 at 06:57
  • Database structure looks like this, Date:14th Feb Model:Phone Model1 Issue:Abc Date:16th Feb Model:PhoneModel2 Issue xyz Here the user will pick a date using DatePicker Dialog , say he picks 16th Feb then I want to display the content dated under 16th. I hope that clarifies. – Palash Jain Feb 17 '19 at 13:51
  • Instead of describing how your database looks like, please add a screenshot of it. – Alex Mamo Feb 17 '19 at 15:19
  • https://i.stack.imgur.com/4dQKg.png – Palash Jain Feb 18 '19 at 19:22

1 Answers1

0

I'm trying to filter firestore content on basis on of a date picked by user. Say Display all data for 14th Feb

You are storing the Date property as a String you are doing it wrong.

To be able to query your database according to a specific date, your Date property should be o type Date and not String. To see how you can achieve this, please take a look at my answer from this post.

Once you have the property set correctly, a query like this should do the trick:

noteBookref.whereEqualTo("Date" , date).orderBy("Date", Query.Direction.DESCENDING).get();

In which date is a Date object representing the date you are looking for. Remember to delete the existing data and add fresh one.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193