# Node Red Nordpool API, need help filtering the message

**URL:** <https://discourse.nodered.org/t/node-red-nordpool-api-need-help-filtering-the-message/70855>\
**Category:** General\
**Created:** [18 November 2022 20:23 UTC](https://discourse.nodered.org/t/node-red-nordpool-api-need-help-filtering-the-message/70855 "2022-11-18T20:23:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![virtaz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/virtaz/32/70682_2.png) [@virtaz](https://discourse.nodered.org/u/virtaz)\
**Post date:** [18 November 2022 20:23 UTC](https://discourse.nodered.org/t/node-red-nordpool-api-need-help-filtering-the-message/70855/1 "2022-11-18T20:23:31Z")

</div>

Hey.  
I'm using a flow copied from here: [https://discourse.nodered.org/t/extract-value-from-array-based-on-timestamp/56954](https://discourse.nodered.org/t/extract-value-from-array-based-on-timestamp/56954)

It's workin ok, but the problem is that the price changes at the wrong time :

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/6/2625351f35fbe3743e6577f2cad45a2527c2eeee.png)

Price change at xx:30, and the price is wrong.

I know the issue is on this function node, its is rounding to nearest hour, as it is saying.

```auto
const data = msg.payload;
const now = new Date();
const nearestHour = roundDate(now);
const findTimestamp = nearestHour.valueOf();

msg.payload = data.find(e => {
    return (new Date(e.Timestamp)).valueOf() == findTimestamp;
});

return msg;

function roundDate(date) {
    date.setHours(date.getHours() -1 + Math.round(date.getMinutes() /60));
    date.setMinutes(0, 0, 0);
    return date;
}

```

But I dont have any idea how to fix it, I'm a total noob with javascript.  
Price should change at xx:00:00 and hold the price to xx:59:59

Any help with function node is highly appriciated 🙂

---

<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:** [18 November 2022 20:54 UTC](https://discourse.nodered.org/t/node-red-nordpool-api-need-help-filtering-the-message/70855/2 "2022-11-18T20:54:38Z")

</div>

This kind of data is meaningful to present with bar chart. Bar per hour. Elegant and easy to read.

---

<div class="post-metadata">

**Author:** ![virtaz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/virtaz/32/70682_2.png) [@virtaz](https://discourse.nodered.org/u/virtaz)\
**Post date:** [19 November 2022 14:56 UTC](https://discourse.nodered.org/t/node-red-nordpool-api-need-help-filtering-the-message/70855/3 "2022-11-19T14:56:28Z")

</div>

Great. I'll keep that in mind.

---

<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:** [18 January 2023 14:57 UTC](https://discourse.nodered.org/t/node-red-nordpool-api-need-help-filtering-the-message/70855/4 "2023-01-18T14:57:04Z")

</div>

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