0

I want to display the data by monthwise in recyclerview, I have a field in firestore db as "delivery_Date"= Timestamp(ServerTimestamp)

I have tried to filter by month wise but it displays empty recyclerview

This is my code in Kotlin

val docRef = db.collection("All Booking ID")
                .whereEqualTo("driverId", auth.currentUser?.uid)
                .whereEqualTo("status","Completed")
                    .whereGreaterThanOrEqualTo("delivery_Date","2021-02")
                    .whereLessThan("delivery_Date","2021-03")
                .orderBy("delivery_Date")


            val options : FirestoreRecyclerOptions<Service> = FirestoreRecyclerOptions.Builder<Service>()
                .setQuery(docRef, Service::class.java)
                .build()


            adapterService = AdapterService(applicationContext, options, this@BarChartCompletedList)
            adapterService?.notifyDataSetChanged()
            recyclerViewServices.layoutManager = LinearLayoutManager(applicationContext)

            recyclerViewServices.adapter = adapterService
            recyclerViewServices.setHasFixedSize(true)

            adapterService?.startListening()

Anybody help me to sort out the results in timestamp field ... Thank You !

  • Your `delivery_Date` property holds a String value and **not** a Date, as needed in order to be able to use `whereGreaterThanOrEqualTo` and `whereLessThan`. Please check the duplicate to see how you can solve this. – Alex Mamo Mar 02 '21 at 07:06
  • I know it is in String and not works but how can i put that String as Timestamp ? – Beginner Dev Mar 02 '21 at 16:26
  • Please see the duplicate. You should use Timestamp object for that. – Alex Mamo Mar 03 '21 at 08:49

0 Answers0