I am tring to query to a Firestore database to a collection and filter by date. I have a Timestamp field (dateStart) and i need to get the results have date today , i don't care about time ,i tried to use this but it works only have same time
My document : 20 septembre 2021 at 01:30:00 UTC 1
refWallet
.where("dateStart", "==", new Date("2021,09,20"))
.get()
CodePudding user response:
You will need a range query with start and end points to cover the intended time. In Firestore, timestamp types are always considered a single point in time and do not have date and time components available. It's the same for Date objects in JavaScript.
refWallet
.where("dateStart", ">=", startDate)
.where("dateStart", "<", endDate)
.get()
If this is not what you want, then you probably shouldn't use a timestamp type field and instead use a string that will give you an exact match. For example, you could store dates as strings formatted YYYYMMDD in order to query for exact dates without ranges.