Comparing a list of items against a single item in another list

Describe the problem/error/question

Hello. I am new, so i am not totally sure on the terminology so will then explain how i would do it in python to make it more clear.

I have a node that outputs a timestamp (its a date object. I have multiple items outputted, this represents the modified time of a series of google docs.

I then have a single item coming out of another node (this may be my error as rather than a single item it might be item 0 in an array…). This is another date object - and is the date i want to test against.

I want to use an if statement (or whatever is best) to test my list of dates in the first node i described, against the single date in the second node i described.

What is the most correct way to do this, so my output is just the items in the first list been sent back out wither as true or false.

Is it best to wire both nodes into my if node, because i seem to be having some issues with telling it that i want to test each item against one single item, i tried to use .first rtc but that doesnt work.

In python i would just loop over the items in my first node and test those against item zero in lost two, and my output would just be true or false list one results.

Help needed and appreciated.
I am used to python and grasshopper which seem to approach this a bit differently.

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: current
  • Database (default: SQLite): Default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): Default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): cloud
  • Operating system: windows

Welcome to the community @samuel_sweeney !

Tip for sharing information

Pasting your n8n workflow


Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.

```
<your workflow>
```

That implies to any JSON output you would like to share with us.

Make sure that you have removed any sensitive information from your workflow and include dummy or pinned data with it!


There are a few ways you could compare two sets of items. The most versatile approach is to utilize Compare Datasets node. The other options include Merge node.

Here’s a small demo.

Set1 has 10 email addresses and Set2 has 1 that is also present in Set1. The Compare Datasets node has 4 ouputs including one for all the matched items and those that do not.

Bear in mind that comparing date/time could be tricky as those typically include miliseconds. To have a match every digit has to match.

This is a screenshot of my issue and it should be easy to fix. Its a bit different as I am comparing dates, so I dont think i can use the compare node (although this is great to know for the future).

I want to look over a series of created times for different files, and compare them against one single time, called LastUpdatedTime.

I beleive the reason why its not working, is it is trying to look at the next item in the LastUpdatedTime (there is only one so it doesnt exist) rather than keeping this fixed. I also tried to call .first() etc but that does not work.

This is the error I am getting when trying to run everything:

When I set it to execute once, it works, that is why I think its an issue with trying to go to the next item in my fixed date. See image below.

I then added a date in as a fixed element, in the image below, to test it, and it works, but I obviously want this to be dynamic rather than static,

This has convinced me I am just having an error getting the first item from the array, I do not really get what I am doing wrong or how to solve this.

I could do this very easilly in python, but I dont really understand how to keep this one date fixed and loop over the rest. Thankyou

edit. I think I have the anwer, rather than calling .item() I needed to call the .first()/.last() etc.

{{ $(‘Limit’).last().json.LastUpdateTime }}

I’d recommend @ihortom’s approach here. Also see this answer to a very similar question for a description of how you’d do it with the ‘merge’ node

Thankyou. Totally get the compare list method. But I tested it with dates and it doesnt seem possible to use, as it just seems to test if its the same or not, rather than ‘is date larger etc’.

Please share your workflow (with the relevant node data pinned) if you’d like help with this. Thanks