# Epoch Time subtraction

**URL:** <https://discourse.nodered.org/t/epoch-time-subtraction/56872>\
**Category:** General\
**Tags:** node-red-dashboard, database, function-node, mqtt\
**Created:** [18 January 2022 17:09 UTC](https://discourse.nodered.org/t/epoch-time-subtraction/56872 "2022-01-18T17:09:44Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![JHScen](https://avatars.discourse-cdn.com/v4/letter/j/45deac/32.png) [@JHScen](https://discourse.nodered.org/u/JHScen)\
**Post date:** [19 January 2022 14:35 UTC](https://discourse.nodered.org/t/epoch-time-subtraction/56872/21 "2022-01-19T14:35:52Z")

</div>

So in my function node,

```auto
msg.payload = msg.payload - msg.payload;
return msg;

```

Is that correct? As with that I'm just getting 0, when it should be 3500

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 January 2022 14:38 UTC](https://discourse.nodered.org/t/epoch-time-subtraction/56872/22 "2022-01-19T14:38:44Z")

</div>

> [@JHScen](#):
>
> So in my function node,
> 
> ```auto
> msg.payload = msg.payload - msg.payload;
> return msg;
> 
> ```
> 
> Is that correct?

no, that would never work.

Imagine `msg.payload` equalled `123`. Then `123 - 123` is always `0`

Show me the output of the join node. AND/OR share your flow as previously asked

> [@Steve-Mcl](#):
>
> Share your flow if you are are still stuck & show us the value that comes from both legs of the flow before the join node (use debug nodes and screenshot the 2 output values)

---

<div class="post-metadata">

**Author:** ![JHScen](https://avatars.discourse-cdn.com/v4/letter/j/45deac/32.png) [@JHScen](https://discourse.nodered.org/u/JHScen)\
**Post date:** [19 January 2022 14:43 UTC](https://discourse.nodered.org/t/epoch-time-subtraction/56872/23 "2022-01-19T14:43:29Z")

</div>

All makes sense. It wasn't working due to the fact that I had a split node included too - therefore the payload message wasn't getting through from both sides.

Removing the split node and copying the path from the join node and placing them in the function allowed me to do the subtraction.

Thanks so much for taking the time Steve.

Best wishes

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 January 2022 14:45 UTC](https://discourse.nodered.org/t/epoch-time-subtraction/56872/24 "2022-01-19T14:45:40Z")

</div>

> [@JHScen](#):
>
> Thanks so much for taking the time Steve.

No bother.

Please mark the answer that best suits your solution (even if that is your post)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 February 2022 14:45 UTC](https://discourse.nodered.org/t/epoch-time-subtraction/56872/25 "2022-02-02T14:45:49Z")

</div>

Closed on 2 February 2022 14:45 UTC

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

[Previous page](https://discourse.nodered.org/t/epoch-time-subtraction/56872.md?page=1)
