11

How can I filter the results on the Firestore Console by a timestamp field?

On the collection users, we have a field createdOn of type timestamp. If I want to filter the collection by field, I get the following dialog

Filter 'user' collection by 'createdOn'

I have tried entering the date as string

  • 2019-09-15
  • 2019-09-15T00:00:00Z

I have also tried using a timestamp as number in millis and seconds

  • 1568505600000
  • 1568505600

When looking at the requests sent to Firestore, the structured query uses a field filter with a value of corresponding to either stringValue or integerValue, but I think the timestampValue would be the right thing.

I do not want to adapt the query in the console and build my own requests. I know that there is always the option to sort the documents in the collection and then scroll to where it's interesting, but this will load all documents that are not relevant.

Is there a simple way to do what I want?

Kariem
  • 4,398
  • 3
  • 44
  • 73
  • 5
    In Firestore Console GUI its not possible to filter by timestamp. I think this GUI is only for support and testing purposes, but it should be working in API. If you need to use it in GUI I suggest to raise a feature request for it: https://firebase.google.com/support/troubleshooter/report – vitooh Feb 04 '21 at 07:45

1 Answers1

2

There is a new query builder tab in the console (I do not know when this was introduced, but I assume during the Firebase Summit 2022). For the query above, this would look like this

Firebase Console with Cloud Firestore, Data Tab / Query Builder

It even has a timestamp type in the select list.

Kariem
  • 4,398
  • 3
  • 44
  • 73