# Integration from Date in Debug

**URL:** <https://discourse.nodered.org/t/integration-from-date-in-debug/73276>\
**Category:** General\
**Tags:** http-request\
**Created:** [6 January 2023 07:27 UTC](https://discourse.nodered.org/t/integration-from-date-in-debug/73276 "2023-01-06T07:27:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![stourel](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@stourel](https://discourse.nodered.org/u/stourel)\
**Post date:** [6 January 2023 07:27 UTC](https://discourse.nodered.org/t/integration-from-date-in-debug/73276/1 "2023-01-06T07:27:26Z")

</div>

Hi everybody,

I am a full beginner by Node-Red, so please excuse me if my explanations are maybe difficult to understand.

I am trying to use a API form Forcast.solar to become the actuel PV estimated yiel.  
Therfore I am using a inject node then a http request node and finally a debug node.  
The http request use this link: [https://api.forecast.solar/estimate/watt\_hours\_day/39.7/2.97/45/0/1.2](https://api.forecast.solar/estimate/watt_hours_day/39.7/2.97/45/0/1.2) (Json object) and it is working fine.  
In the debug I am using msg. payload.result to obtain the kwh. The Api provide the kwh for today and tomorrow. I would like to isolate the value for the catual day.  
To do that I can e.g in the debug use msg.payload.result["2023-01-06"]. But the date is changing every day.  
So how can I integrate the actual date in the debug to make sure, it will actualize the date in the request?  
I hope you can understand.

Best and happy new year.

Syl

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 January 2023 07:31 UTC](https://discourse.nodered.org/t/integration-from-date-in-debug/73276/2 "2023-01-06T07:31:45Z")

</div>

Hi and welcome to the forum.

I am not sure this question falls under the `creating nodes` category.  
(That is for people wanting to make their own nodes)

Could you change the request to `general` rather than this one?

---

<div class="post-metadata">

**Author:** ![stourel](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@stourel](https://discourse.nodered.org/u/stourel)\
**Post date:** [6 January 2023 07:56 UTC](https://discourse.nodered.org/t/integration-from-date-in-debug/73276/3 "2023-01-06T07:56:12Z")

</div>

Hi?  
Thank you very much for the advice.

I changed it already.

Best

Syl

---

<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:** [6 January 2023 07:59 UTC](https://discourse.nodered.org/t/integration-from-date-in-debug/73276/4 "2023-01-06T07:59:45Z")

</div>

You could convert the `msg.payload.result` to an array. Then `msg.payload.result[0]` will be today, and `msg.payload.result[1]` would be tomorrow. But it relies on the object having same layout each time.  
e.g.

```auto
[{"id":"1443affe2a15c0ed","type":"inject","z":"da8a6ef0b3c9a5c8","name":"","props":[{"p":"url","v":"https://api.forecast.solar/estimate/watt_hours_day/39.7/2.97/45/0/1.2","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":2820,"wires":[["0aaf17df539748e2"]]},{"id":"0aaf17df539748e2","type":"http request","z":"da8a6ef0b3c9a5c8","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":350,"y":2820,"wires":[["715b5ab2d3b28abb"]]},{"id":"715b5ab2d3b28abb","type":"change","z":"da8a6ef0b3c9a5c8","name":"","rules":[{"t":"set","p":"payload.result","pt":"msg","to":"$$.payload.result.*","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":2820,"wires":[["a91123f4e56d6d55"]]},{"id":"a91123f4e56d6d55","type":"debug","z":"da8a6ef0b3c9a5c8","name":"debug 223","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":690,"y":2860,"wires":[]}]

```

Or you could use a more complicated expression and create the date strings require to address your values.  
e.g.

```auto
[{"id":"1443affe2a15c0ed","type":"inject","z":"da8a6ef0b3c9a5c8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"result\":{\"2023-01-06\":4568,\"2023-01-07\":4514},\"message\":{\"code\":0,\"type\":\"success\",\"text\":\"\",\"info\":{\"latitude\":39.7,\"longitude\":2.97,\"distance\":0,\"place\":\"Camí de Tirasset, Inca, Raiguer, Illes Balears, 07430, España\",\"timezone\":\"Europe/Madrid\",\"time\":\"2023-01-06T08:42:46+01:00\",\"time_utc\":\"2023-01-06T07:42:46+00:00\"},\"ratelimit\":{\"period\":3600,\"limit\":12,\"remaining\":8}}}","payloadType":"json","x":150,"y":2800,"wires":[["7f239f293c096fb5"]]},{"id":"7f239f293c096fb5","type":"change","z":"da8a6ef0b3c9a5c8","name":"","rules":[{"t":"set","p":"payload.today","pt":"msg","to":"$lookup($$.payload.result,$moment().format(\"YYYY-MM-DD\"))","tot":"jsonata"},{"t":"set","p":"payload.tomorrow","pt":"msg","to":"$lookup($$.payload.result,$moment().add(1, \"day\").format(\"YYYY-MM-DD\"))","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":2800,"wires":[["a91123f4e56d6d55"]]},{"id":"a91123f4e56d6d55","type":"debug","z":"da8a6ef0b3c9a5c8","name":"debug 223","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":570,"y":2840,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![stourel](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@stourel](https://discourse.nodered.org/u/stourel)\
**Post date:** [6 January 2023 14:18 UTC](https://discourse.nodered.org/t/integration-from-date-in-debug/73276/5 "2023-01-06T14:18:53Z")

</div>

Thank you so much. It works like a charm. I am still learning on the code. Have a nice weekend

---

<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:** [7 March 2023 14:19 UTC](https://discourse.nodered.org/t/integration-from-date-in-debug/73276/6 "2023-03-07T14:19:47Z")

</div>

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