Date filter with if node and code node


hello community! How are you doing? me again! Sorry haha

I wanted to tell you that I am having a problem when filtering items, for example I have in the node “code” where I get the current date and in another node I have other dates, the problem is that when I place to filter the date with the code node, it is only comparing it with the first item that enters and not with the 730 that there are, now if I place the manual date in plain text, it compares it with all items, any idea what can be?

As always, thank you very much for your help!

Hi @Internalit_Automatio, based on your description I suspect your dia_code node returns only one item, could this be? If so, you would need to tell your If node to always read this first item, for example using an expression like this:

{{ $("dia_code").first().json.fecha }}

Without the .first() part (documented here), the If node would pull the first item of the dia_code node for its own first item which works. Then for the second item it would try to pull the second item of the dia_code node which fails, same for the third, fourth etc. item.

I hope this makes sense and helps! Let me know if that’s not it or if you have any further questions here :slight_smile:


Hi @MutedJam
First of all I would like to thank you for the help you have always given me! :green_heart:

And here comes the question, I do not know if I understood correctly but I put: {{ $(“dia_code”).all().json.fecha }} and I get an error, if I put last, first, it takes it well but of course, it does not compare it with all items, maybe something is wrong? My dia_code node has this configuration:


Oh, looks like your dia_code node returns the current data but only applies it to the first item indicated by items[0].

Is your goal simply to get today’s date? If so you could consider removing this Code node completely, and instead use an expression like {{ $now.setZone("America/Buenos_Aires").toFormat("yyyy-MM-dd") }} directly on the IF node:


This way, you wouldn’t have to worry about other nodes at all and will compare today’s date for each incoming item :slight_smile:


Oh my god you are amazing, always helping me and solving things!!! :heart: That worked for me! So you mean that if I want to get date, day, time “current” I can put directly in the IF and it compares everything, incredible!!! Thanks so much for the help and have a great week!!!



Thank you so much for your kind words, glad to hear this works for you :blush:

1 Like

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