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
AI Support
AI Support2mo ago
Processing...
🤖 Gathering bytes and bits. 🧲 this might take a couple of minutes... beep boop
AI Support
AI Support2mo ago
🤖 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:
{
"field": "plan_ends",
"operator": "<",
"value": "{{currentDatePlusOne}}"
}
{
"field": "plan_ends",
"operator": "<",
"value": "{{currentDatePlusOne}}"
}
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
Chinmay Khandelwal
Chinmay KhandelwalOP2mo ago
please if a human is seeing this please help me
Gaurav Chadha
Gaurav Chadha5w ago
Hi @Chinmay Khandelwal were you able to check the above references? It does contains examples to query with timestamp
Chinmay Khandelwal
@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
Chinmay Khandelwal
Okay that was the issue @Gaurav Chadha

Did you find this page helpful?