Set date as KEY in Real Time DataBase

How can i set “todays date” as the key in a Firebase Reatime DB?
When i create a new variable as Cloud i cant (but i might just not see it)
I want to use the Todays date as key and underneeth, load varios statistics (for each day the obviously)
for example

12 November 2022:
Stat A: 5
Stat B: 7
Stat C: 6

13 November 2022:
Stat A: 2
Stat B: 8
Stat C: 3

Any best practices just to get me going ?

1 Like

It’s possible to do that with this block:


Try this:

That returns the date as this:


You can also use Javascript to get the current date in the format you want and then add that variable block to the “name” section of the block in the screenshot above. The command I have in my script is:

new Date().toLocaleDateString()

That returns the date in this format for where I live:


So I use that as the key value in Firebase but I replace the slashes with dashes because I wasn’t sure if slashes would affect the data path:



Firebase RTDB (Real Time Database) does not have the concept of having a record with a KEY.
In standard databases a key field will not allow the user to duplicate records using the same KEY but this is not available in Firebase RTDB.

This would mean that you have to code the verification process yourself.