# Test payload for date.now+1

**URL:** <https://discourse.nodered.org/t/test-payload-for-date-now-1/46820>\
**Category:** General\
**Created:** [7 June 2021 15:16 UTC](https://discourse.nodered.org/t/test-payload-for-date-now-1/46820 "2021-06-07T15:16:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![monsivar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/monsivar/32/40032_2.png) [@monsivar](https://discourse.nodered.org/u/monsivar)\
**Post date:** [7 June 2021 15:16 UTC](https://discourse.nodered.org/t/test-payload-for-date-now-1/46820/1 "2021-06-07T15:16:50Z")

</div>

I have an payload "payload.date" with format "2021-06-18"

How to write an function to check if the payload.date is today's date+1 day

If its true, forward message, if not, stop the message

Regards  
Mons

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 June 2021 16:01 UTC](https://discourse.nodered.org/t/test-payload-for-date-now-1/46820/2 "2021-06-07T16:01:22Z")

</div>

Where is that coming from? If that comes from, for example, a Date object, then it may be simple.  
Otherwise you could use `new Date()` to give you a date object, add a day to it, then convert that to an ISO string with the appropriate time zone and compare the date part of the string with the string you have.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [7 June 2021 16:35 UTC](https://discourse.nodered.org/t/test-payload-for-date-now-1/46820/3 "2021-06-07T16:35:45Z")

</div>

here is an example using JSONata expression an $moment(), it would be better if you feed a time in to

```auto
[{"id":"e4f5e458.7a6d1","type":"inject","z":"e169487f.02ad68","name":"201-96-08","props":[{"p":"payload.date","v":"2021-06-08","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":290,"y":140,"wires":[["322c5eec.745b0a"]]},{"id":"322c5eec.745b0a","type":"change","z":"e169487f.02ad68","name":"","rules":[{"t":"set","p":"datecheck","pt":"msg","to":"$moment(payload.date).subtract(1,\"days\").isAfter( $moment())","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":160,"wires":[["fe9ecc06.cc0f28"]]},{"id":"fe9ecc06.cc0f28","type":"switch","z":"e169487f.02ad68","name":"","property":"datecheck","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":600,"y":200,"wires":[["f2878f0a.4a8d88"]]},{"id":"fec467b9.cddcb8","type":"inject","z":"e169487f.02ad68","name":"201-96-09","props":[{"p":"payload.date","v":"2021-06-09","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":290,"y":180,"wires":[["322c5eec.745b0a"]]},{"id":"f2878f0a.4a8d88","type":"debug","z":"e169487f.02ad68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":180,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![monsivar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/monsivar/32/40032_2.png) [@monsivar](https://discourse.nodered.org/u/monsivar)\
**Post date:** [7 June 2021 20:57 UTC](https://discourse.nodered.org/t/test-payload-for-date-now-1/46820/4 "2021-06-07T20:57:18Z")

</div>

Thanks for the help 🙂

---

<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:** [21 June 2021 20:58 UTC](https://discourse.nodered.org/t/test-payload-for-date-now-1/46820/5 "2021-06-21T20:58:11Z")

</div>

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