# Store a value in a function

**URL:** https://discourse.nodered.org/t/store-a-value-in-a-function/990
**Category:** FAQs
**Created:** [21 June 2018 16:51 UTC](https://discourse.nodered.org/t/store-a-value-in-a-function/990 "2018-06-21T16:51:28Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Sjoerd](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@Sjoerd](https://discourse.nodered.org/u/Sjoerd)
#### Post date: [21 June 2018 16:51 UTC](https://discourse.nodered.org/t/store-a-value-in-a-function/990/1 "2018-06-21T16:51:29Z")

</div>

Is there a way to store a value in a function node for future use? I want to do the following: A message contains a certain variable with a certain value. This message is received every 5 minutes. I want to compare the value of the variable with the value from the previous message and act upon the difference. Is that possible with a function node or should I use some other node?

Regards

Sjoerd van Staveren

---

<div class="post-metadata">

### Author: ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)
#### Post date: [21 June 2018 16:56 UTC](https://discourse.nodered.org/t/store-a-value-in-a-function/990/2 "2018-06-21T16:56:56Z")

</div>

Directly from docs: [https://nodered.org/docs/writing-functions#storing-data](https://nodered.org/docs/writing-functions#storing-data)

---

<div class="post-metadata">

### Author: ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)
#### Post date: [21 June 2018 17:01 UTC](https://discourse.nodered.org/t/store-a-value-in-a-function/990/3 "2018-06-21T17:01:20Z")

</div>

You can also store and retrieve the values using a change node

---

<div class="post-metadata">

### Author: ![Sjoerd](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@Sjoerd](https://discourse.nodered.org/u/Sjoerd)
#### Post date: [21 June 2018 17:01 UTC](https://discourse.nodered.org/t/store-a-value-in-a-function/990/4 "2018-06-21T17:01:53Z")

</div>

Oh dear, I should be ashamed of myself. Thank you for the quick response.

---

<div class="post-metadata">

### Author: ![Energycharges](https://avatars.discourse-cdn.com/v4/letter/e/e47c2d/32.png) [@Energycharges](https://discourse.nodered.org/u/Energycharges)
#### Post date: [24 September 2020 04:45 UTC](https://discourse.nodered.org/t/store-a-value-in-a-function/990/5 "2020-09-24T04:45:35Z")

</div>

appecriate , if you can share me your sample code that u have written to get the values between 5 min interval.

Thanks

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [24 September 2020 08:09 UTC](https://discourse.nodered.org/t/store-a-value-in-a-function/990/6 "2020-09-24T08:09:16Z")

</div>

@Energycharges - two things  
1 - did you read the documentation mentiond in this thread??  
2 - this thread is over two years old so I'm going to close it. If you continue to have an issue after reading the documentation, please start a new thread explaining what you have tried and what you are trying to do. Thanks!

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [24 September 2020 08:09 UTC](https://discourse.nodered.org/t/store-a-value-in-a-function/990/7 "2020-09-24T08:09:20Z")

</div>


