How to Query Firestore document using a field which is of type timestamp
can some please tell me how can i filter firestore document using a field which is of type timestamp ( i want to filter all the documents which had field (plan_ends) which is of type timestamp less than current day + 1 time
7 Replies
Processing...
🤖 Gathering bytes and bits. 🧲 this might take a couple of minutes... beep boop
🤖 AI Response
To filter Firestore documents by a timestamp field using the BuildShip Collection Query node, you should use a filter structure specifying the field, operator, and a value representing tomorrow's date as a timestamp. The recommended approach is to generate the "currentDatePlusOne" variable using a JavaScript node, which calculates tomorrow's date at midnight and returns it for use in the query. The filter should look like:
This approach aligns with BuildShip's documentation, which confirms that Firestore comparison operators such as "<" work for timestamp fields. However, ensure that the timestamp format you generate matches what Firestore expects (typically a JavaScript Date object or Firestore Timestamp). If you encounter issues with date formats, refer to BuildShip's support documentation for updates on handling Firestore timestamps, as there have been recent changes in how date formats are managed in BuildShip nodes.
🔗 References:
1. https://support.buildship.com/m/1322893819091484733
2. https://support.buildship.com/m/1245717376398393344
3. https://community.flutterflow.io/ask-the-community/post/issue-with-filtering-firebase-with-data-entry-date-stamp-OGtmFPu68Wd5FIa
4. https://support.buildship.com/m/1253268120936910939
5. https://cloud.google.com/firestore/native/docs/query-data/queries
BuildShip AI Support
please if a human is seeing this please help me
Hi @Chinmay Khandelwal were you able to check the above references? It does contains examples to query with timestamp
@Gaurav Chadha yes the problem is resolved but just want to know why the "=" operator do not work and for th esame expression "<="and ">=" works
or may be i don't know how to use it while filtering time stamp field@Gaurav Chadha
use
==
instead, single =
is an assignment operator. https://firebase.google.com/docs/firestore/query-data/queriesOkay that was the issue @Gaurav Chadha