Addressing field for all objects in array

Describe the problem/error/question

My HTTP Request node returns an array with multiple objects which themselves are arrays. I want to filter using the If node to only select objects where the created_at date is within the last 24 hours - but I can only seem to apply it to an individual object:

What is the error message (if any)?

I don’t know how to address the field all objects in an array - something like this doesn’t work (and to be honest I didn’t think it would either):

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

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

You can use the Split Out Node for this purpose.

Regarding the topic of age and dealing about date/time: I personally find it much simpler and easier to understand when using something like difference in days as a basis. To make things clearer, I’ve adjusted the query accordingly: {{ ($today - new Date($json.created_at)) / (1000 * 60 * 60 * 24) }} → age in days. Of course, this is just a personal preference that helps me understand things more easily.
The SET nodes at the end are simply for verification purposes, to check what comes out at each step.

1 Like

Hahah, that was literally the first thing I tried but I used the expression {{ $json.data }} instead of just the fixed “data” string, that gave me the error “this.getNodeParameter(…).split is not a function”.

I spent nearly half an hour trying to troubleshoot that before going down other rabbitholes, but still don’t understand why the fixed string worked but referencing the same array using Javascript didn’t - do you know?

Also thanks for the suggestion for calculating the difference in timestamps, I hadn’t thought of that!

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