Datewise data retrieval from Firebase

Hi,

I am sending data to Firebase with a date range (From & To date). I then want to read data from Firebase for a specific date. How do I do it?

Thanks

shirohin6,

I am not aware of any built-in Thunkable functions to search the Firebase Realtime DB using criteria.

The only way I have found is to loop through the JSON (for each … In List…) and create blocks to compare dates (if value >= XXX and value <= YYY THEN ). Make sure in Firebase you set the date format to YYYY-MM-DD or parsing the date will be a nightmare. When saving dates, be sure to use leading zeros on MM and DD, otherwise your >= and <= comparsions may not work correctly.

This solution will require a LOT of block and will depend on the structure of your JSON tree. I would recommend you wrap all of those blocks into a function with at least 3 input parameters: 1)JSON list to search, 2) start date, 3) end date, with a return value of the matching object.

Good Luck, Happy Thunking!

1 Like

Thanks Drted. I was thinking on the same lines and was able to do it.