Need help with sorting a string for dates

Hi

I'm trying to sort an string of dates and then split the string and send the first date as payload.

The business case is that i got a json file from my renovation company that contains pickup dates for my different types of trash, and i want to use the dates for showing an notifying in Home assistant

My flow that ends in the string of dates (containing the json data) is like this:

[{"id":"8f4c55dc.520918","type":"inject","z":"a318c51d.29a138","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"name\":\"Restavfall\",\"date\":\"2021-12-17\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-05-04\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-05-20\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-06-04\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-06-18\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-02\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-16\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-30\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-08-13\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-08-27\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-09-10\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-09-24\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-10-08\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-10-22\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-11-05\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-11-19\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-04-20\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-12-03\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-04-20\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-06-18\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-11-05\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-11-19\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-12-03\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-09-24\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-09-10\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-08-27\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-08-13\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-30\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-16\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-02\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-10-22\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-10-08\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-05-20\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-12-17\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-05-04\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-06-04\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-12-17\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-11-19\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-10-22\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-05-04\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-09-24\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-08-27\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-07-30\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-07-02\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-06-04\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-07-30\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-11-19\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-09-24\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-06-04\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-10-22\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-09-24\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-08-27\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-07-30\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-07-02\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-06-04\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-05-04\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-12-17\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-11-19\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4}]","payloadType":"json","x":180,"y":580,"wires":[["386ee4ad.4e547c"]]},{"id":"386ee4ad.4e547c","type":"split","z":"a318c51d.29a138","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":true,"addname":"","x":480,"y":640,"wires":[["13dd80cc.14bebf"]]},{"id":"13dd80cc.14bebf","type":"switch","z":"a318c51d.29a138","name":"","property":"payload.name","propertyType":"msg","rules":[{"t":"eq","v":"Restavfall","vt":"str"},{"t":"eq","v":"Matavfall","vt":"str"},{"t":"eq","v":"Plast","vt":"str"},{"t":"eq","v":"Papir, papp og kartong","vt":"str"},{"t":"eq","v":"Glass- og metallemballasje","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":700,"y":640,"wires":[["53054a07.e52f64"],["d9f3cbcb.d29178"],["b984f0b3.ef20c"],["ff99496c.aa1d08"],["bc01472.69bcab8"]]},{"id":"53054a07.e52f64","type":"change","z":"a318c51d.29a138","name":"","rules":[{"t":"move","p":"payload.name","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":380,"wires":[["61eafcbd.d01db4"]]},{"id":"61eafcbd.d01db4","type":"change","z":"a318c51d.29a138","name":"","rules":[{"t":"move","p":"payload.date","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":420,"wires":[["317384a6.4c7dec"]]},{"id":"317384a6.4c7dec","type":"batch","z":"a318c51d.29a138","name":"","mode":"interval","count":10,"overlap":0,"interval":10,"allowEmptySequence":false,"topics":[],"x":870,"y":460,"wires":[["ca031751.21ce98"]]},{"id":"ca031751.21ce98","type":"join","z":"a318c51d.29a138","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":",","joinerType":"str","accumulate":false,"timeout":"10","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":990,"y":460,"wires":[["7085436e.78c62c"]]},{"id":"7085436e.78c62c","type":"debug","z":"a318c51d.29a138","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1270,"y":360,"wires":[]},{"id":"1befde2.864f922","type":"api-call-service","z":"a318c51d.29a138","name":"Restaavfall","server":"ec6b4330.077a3","version":1,"debugenabled":false,"service_domain":"input_datetime","service":"set_datetime","entityId":"input_datetime.hra_restavfall","data":"{\"date\": {{payload}}}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":true,"x":1170,"y":460,"wires":[[]]},{"id":"ec6b4330.077a3","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

The result is:

2021-12-17,2021-05-04,2021-05-20,2021-06-04,2021-06-18,2021-07-02,2021-07-16,2021-07-30,2021-08-13,2021-08-27,2021-09-10,2021-09-24,2021-10-08,2021-10-22,2021-11-05,2021-11-19,2021-04-20,2021-12-03

The output/ next steps i want is an payload with the first date from time.now, so that i can use the service "set_datetime" for setting a date in Home assistant.

My flow can probably be easier, (and i'm doing 5 equal set dates from the switch, only listed one), but i got the string of dates as an output, and are happy with that. Now i'm just struggling to handle the result.

Hopefully someone can guide an help me towards the goal, and my coding skills is on an noob level.

Regards
Mons

This might get you close...

demo flow...

[{"id":"18d3735a.2a5d6d","type":"inject","z":"7cd4c815.37b668","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"name\":\"Restavfall\",\"date\":\"2021-12-17\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-05-04\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-05-20\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-06-04\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-06-18\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-02\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-16\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-30\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-08-13\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-08-27\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-09-10\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-09-24\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-10-08\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-10-22\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-11-05\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-11-19\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-04-20\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-12-03\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-04-20\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-06-18\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-11-05\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-11-19\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-12-03\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-09-24\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-09-10\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-08-27\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-08-13\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-30\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-16\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-02\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-10-22\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-10-08\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-05-20\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-12-17\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-05-04\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-06-04\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-12-17\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-11-19\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-10-22\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-05-04\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-09-24\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-08-27\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-07-30\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-07-02\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-06-04\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-07-30\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-11-19\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-09-24\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-06-04\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-10-22\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-09-24\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-08-27\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-07-30\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-07-02\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-06-04\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-05-04\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-12-17\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-11-19\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4}]","payloadType":"json","x":290,"y":960,"wires":[["eca01c44.bdf6c"]]},{"id":"eca01c44.bdf6c","type":"function","z":"7cd4c815.37b668","name":"","func":"var now = new Date(0);\n\nvar data = msg.payload;\nif(!data || !Array.isArray(data) || !data.length) {\n    node.warn(\"no data\");\n    return null; //halt flow\n}\n\n//filter the data to today or later\nvar filtered = data.filter(e => new Date(e.date) >= now )\n\n//a compare function\nfunction compare( a, b ) {\n  if ( a.date < b.date ) return -1;\n  if ( a.date > b.date ) return 1;\n  return 0;\n}\n//sort data using the compare function\nvar dataSorted = filtered.sort(compare);\n\n//grab the top (earliest) entry - put it in payload\nmsg.payload = dataSorted[0];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":450,"y":960,"wires":[["d0963b0e.50ca48"]]},{"id":"d0963b0e.50ca48","type":"debug","z":"7cd4c815.37b668","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":960,"wires":[]}]

Try sorting the object before splitting it
e.g.

[{"id":"8f4c55dc.520918","type":"inject","z":"5a245aa1.510164","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"name\":\"Restavfall\",\"date\":\"2021-12-17\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-05-04\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-05-20\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-06-04\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-06-18\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-02\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-16\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-30\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-08-13\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-08-27\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-09-10\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-09-24\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-10-08\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-10-22\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-11-05\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-11-19\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-04-20\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-12-03\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-04-20\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-06-18\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-11-05\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-11-19\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-12-03\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-09-24\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-09-10\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-08-27\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-08-13\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-30\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-16\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-02\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-10-22\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-10-08\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-05-20\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-12-17\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-05-04\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-06-04\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-12-17\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-11-19\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-10-22\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-05-04\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-09-24\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-08-27\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-07-30\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-07-02\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-06-04\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-07-30\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-11-19\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-09-24\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-06-04\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-10-22\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-09-24\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-08-27\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-07-30\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-07-02\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-06-04\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-05-04\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-12-17\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-11-19\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4}]","payloadType":"json","x":690,"y":3500,"wires":[["b6e2de6c.19901"]]},{"id":"b6e2de6c.19901","type":"change","z":"5a245aa1.510164","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[*]^(date)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":3460,"wires":[["386ee4ad.4e547c"]]},{"id":"386ee4ad.4e547c","type":"split","z":"5a245aa1.510164","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":230,"y":3660,"wires":[["13dd80cc.14bebf"]]},{"id":"13dd80cc.14bebf","type":"switch","z":"5a245aa1.510164","name":"","property":"payload.name","propertyType":"msg","rules":[{"t":"eq","v":"Restavfall","vt":"str"},{"t":"eq","v":"Matavfall","vt":"str"},{"t":"eq","v":"Plast","vt":"str"},{"t":"eq","v":"Papir, papp og kartong","vt":"str"},{"t":"eq","v":"Glass- og metallemballasje","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":380,"y":3560,"wires":[["53054a07.e52f64"],[],[],[],[]]},{"id":"53054a07.e52f64","type":"change","z":"5a245aa1.510164","name":"","rules":[{"t":"move","p":"payload.name","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":3560,"wires":[["61eafcbd.d01db4"]]},{"id":"61eafcbd.d01db4","type":"change","z":"5a245aa1.510164","name":"","rules":[{"t":"move","p":"payload.date","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":3560,"wires":[["ca031751.21ce98"]]},{"id":"ca031751.21ce98","type":"join","z":"5a245aa1.510164","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":",","joinerType":"str","accumulate":false,"timeout":"10","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":710,"y":3640,"wires":[["7085436e.78c62c"]]},{"id":"7085436e.78c62c","type":"debug","z":"5a245aa1.510164","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":930,"y":3640,"wires":[]}]

you could even do the whole thing in a single change node
eg.

[{"id":"8f4c55dc.520918","type":"inject","z":"5a245aa1.510164","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Restavfall","payload":"[{\"name\":\"Restavfall\",\"date\":\"2021-03-17\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-05-04\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-05-20\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-06-04\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-06-18\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-02\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-16\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-30\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-08-13\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-08-27\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-09-10\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-09-24\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-10-08\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-10-22\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-11-05\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-11-19\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-04-20\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-12-03\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-04-20\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-06-18\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-11-05\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-11-19\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-12-03\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-09-24\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-09-10\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-08-27\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-08-13\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-30\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-16\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-02\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-10-22\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-10-08\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-05-20\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-12-17\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-05-04\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-06-04\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-12-17\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-11-19\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-10-22\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-05-04\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-09-24\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-08-27\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-07-30\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-07-02\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-06-04\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-07-30\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-11-19\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-09-24\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-06-04\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-10-22\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-09-24\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-08-27\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-07-30\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-07-02\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-06-04\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-05-04\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-12-17\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-11-19\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4}]","payloadType":"json","x":490,"y":3600,"wires":[["b6e2de6c.19901"]]},{"id":"b6e2de6c.19901","type":"change","z":"5a245aa1.510164","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[name=$$.topic and date > $moment().format(\"YYYY-MM-DD\")]^(date)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":3600,"wires":[["7085436e.78c62c"]]},{"id":"7085436e.78c62c","type":"debug","z":"5a245aa1.510164","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload.date","statusType":"msg","x":890,"y":3620,"wires":[]}]

Thanks.

This is absolutely in the right direction and list 1 of 5 dates i want. In the JSON the different types is sorted by name. So an parameter in the function for filtering by payload.name: xx ?, and i can reuse this function

sounds good. pass the name in msg.topic and add to the filter step...

var now = new Date();

var data = msg.payload;
if(!data || !Array.isArray(data) || !data.length) {
    node.warn("no data");
    return null; //halt flow
}

//filter the data to today or later AND where name == topic
var filtered = data.filter(e => new Date(e.date) >= now && e.name == msg.topic )

//a compare function
function compare( a, b ) {
  if ( a.date < b.date ) return -1;
  if ( a.date > b.date ) return 1;
  return 0;
}
//sort data using the compare function
var dataSorted = filtered.sort(compare);

//grab the top (earliest) entry - put it in payload
msg.payload = dataSorted[0];

return msg;

image

How is the Change node formated here?

pretty much as the title on the change node describes.

Here is the demo flow...

[{"id":"ee08c041.f25f3","type":"inject","z":"7cd4c815.37b668","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"name\":\"Restavfall\",\"date\":\"2021-12-17\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-05-04\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-05-20\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-06-04\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-06-18\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-02\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-16\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-07-30\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-08-13\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-08-27\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-09-10\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-09-24\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-10-08\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-10-22\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-11-05\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-11-19\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-04-20\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Restavfall\",\"date\":\"2021-12-03\",\"fractionId\":9999,\"fractionGuid\":\"b4bbf08d-30f0-4024-9f53-e42229ec48a6\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-04-20\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-06-18\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-11-05\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-11-19\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-12-03\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-09-24\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-09-10\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-08-27\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-08-13\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-30\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-16\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-07-02\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-10-22\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-10-08\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-05-20\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-12-17\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-05-04\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Matavfall\",\"date\":\"2021-06-04\",\"fractionId\":2110,\"fractionGuid\":\"ccdd09f5-3510-43bb-9bb4-2b192230d354\",\"route\":30403,\"routeName\":\"0304\",\"frequency\":2,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-12-17\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-11-19\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-10-22\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-05-04\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-09-24\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-08-27\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-07-30\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-07-02\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Papir, papp og kartong\",\"date\":\"2021-06-04\",\"fractionId\":2400,\"fractionGuid\":\"8998844f-406e-458c-b8da-8e8249f5c321\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-07-30\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-11-19\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-09-24\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Glass- og metallemballasje\",\"date\":\"2021-06-04\",\"fractionId\":2612,\"fractionGuid\":\"2627574c-db98-4d6b-94fd-dfb47a64007d\",\"route\":161408,\"routeName\":\"1614\",\"frequency\":8,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-10-22\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-09-24\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-08-27\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-07-30\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-07-02\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-06-04\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-05-04\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-12-17\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4},{\"name\":\"Plast\",\"date\":\"2021-11-19\",\"fractionId\":3200,\"fractionGuid\":\"03fc89dd-accb-4b4f-a6b0-667438975720\",\"route\":100402,\"routeName\":\"1004\",\"frequency\":4,\"startDay\":4}]","payloadType":"json","x":250,"y":1000,"wires":[["73188c9.19ebf74","27c6982c.541698"]]},{"id":"cc42ae3.94b225","type":"function","z":"7cd4c815.37b668","name":"","func":"var now = new Date();\n\nvar data = msg.payload;\nif(!data || !Array.isArray(data) || !data.length) {\n    node.warn(\"no data\");\n    return null; //halt flow\n}\n\n//filter the data to today or later AND where name == topic\nvar filtered = data.filter(e => new Date(e.date) >= now && e.name == msg.topic )\n\n//a compare function\nfunction compare( a, b ) {\n  if ( a.date < b.date ) return -1;\n  if ( a.date > b.date ) return 1;\n  return 0;\n}\n//sort data using the compare function\nvar dataSorted = filtered.sort(compare);\n\n//grab the top (earliest) entry - put it in payload\nmsg.payload = dataSorted[0];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":1000,"wires":[["bda7c5.e1ba5838"]]},{"id":"bda7c5.e1ba5838","type":"debug","z":"7cd4c815.37b668","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":1000,"wires":[]},{"id":"73188c9.19ebf74","type":"change","z":"7cd4c815.37b668","name":"topic = Restavfall","rules":[{"t":"set","p":"topic","pt":"msg","to":"Restavfall","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":1000,"wires":[["cc42ae3.94b225"]]},{"id":"27c6982c.541698","type":"change","z":"7cd4c815.37b668","name":"topic = Matavfall","rules":[{"t":"set","p":"topic","pt":"msg","to":"Matavfall","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":1040,"wires":[["cc42ae3.94b225"]]}]

Now i understand. Thanks for the help