# Set date as KEY in Real Time DataBase

**URL:** https://community.thunkable.com/t/set-date-as-key-in-real-time-database/2155686
**Category:** Questions about Thunkable X
**Created:** [November 29, 2022, 3:51pm UTC](https://community.thunkable.com/t/set-date-as-key-in-real-time-database/2155686 "2022-11-29T15:51:57Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![stefansladdeneng1](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/stefansladdeneng1/32/170123_2.png) [@stefansladdeneng1](https://community.thunkable.com/u/stefansladdeneng1)
#### Post date: [November 29, 2022, 3:51pm UTC](https://community.thunkable.com/t/set-date-as-key-in-real-time-database/2155686/1 "2022-11-29T15:51:57Z")

</div>

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 ?  
thanks  
Stefan

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [November 29, 2022, 3:59pm UTC](https://community.thunkable.com/t/set-date-as-key-in-real-time-database/2155686/2 "2022-11-29T15:59:33Z")

</div>

It’s possible to do that with this block:

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/3/83835372e2ec4d77db1303108ac425b06306bc2e.png)

Try this:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/5/d5cc587d4a9363fc406fe7685a40b7bfd7cd267b.png)

That returns the date as this:

`11292022`

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:

`11/29/2022`

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:

`11-29-2022`

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [December 1, 2022, 10:01am UTC](https://community.thunkable.com/t/set-date-as-key-in-real-time-database/2155686/3 "2022-12-01T10:01:47Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)
#### Post date: [March 1, 2023, 10:01am UTC](https://community.thunkable.com/t/set-date-as-key-in-real-time-database/2155686/4 "2023-03-01T10:01:56Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
