I realized there is a strange behavior when using a where() clause on a Timestamp field in a Firestore query(). I'm using the modular version 9 of Firebase.
Maybe someone has an explanation for that.
So here's the data I see in the Firebase/Firestore console:
Assuming, that today is the 27th December 2021, I want to query all documents for this day - in this case, only the one document from above.
I would use the following query (i.e. everything after today at midnight and before tomorrow at midnight):
const today = new Date(new Date().setHours(0,0,0));
const tomorrow = new Date(new Date(today).setDate(today.getDate() + 1));
const docQuery = query(collection(getFirestore(firebaseApp), 'ticks1'),
where('date', '>=', today),
where('date', '<', tomorrow)
)
const querySnapshot = await getDocs(docQuery)
console.log('documents count:', querySnapshot.docs.length)
But: this returns no results!
documents count: 0
Instead, if I change the value in the database to 12:00:01 AM (see below), it works and I retrieve the expected document.
documents count: 1
Can somebody explain this behavior - or is it a bug in the Firestore implementation?

