If node with dates and times - ERROR: The value "undefined" is not a valid DateTime

Hello,

I can’t understand why I can’t compare these dates.

The problem seems to come from the “now_CET” value but I can’t figure out why.

Anyone see why ?

Thanks in advance for your help.

This is the error message:

Stack
NodeOperationError: The value "undefined" is not a valid DateTime.
    at convertDateTime (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/If/If.node.js:376:23)
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/If/If.node.js:394:34)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:658:51)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:585:68
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

The worflow:

`{
  "meta": {
    "instanceId": "72786ae79aa2a39c713dd21fa0afbb75d22cf8ceb717141469d817c1b9d4a238"
  },
  "nodes": [
    {
      "parameters": {
        "conditions": {
          "dateTime": [
            {
              "value1": "={{ $json[\"last_notif_CET\"] }}",
              "value2": "={{ $node[\"Now CET\"].json[\"now_CET\"] }}"
            }
          ]
        }
      },
      "id": "6e9d0b24-d0cc-4141-99fa-4443e2bf5f3b",
      "name": "IF > 45 min last notif  AND > 1h from the window start",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1280,
        -40
      ]
    }
  ],
  "connections": {}
}`

Some screenshots:


Hi @Clapp_Prod, welcome to the community :tada:

It seems you have one item coming from your “Now CET” node, but 3 items coming from the “Last notif CET” node. Assuming the the “Last notif CET” node is the node connected to your IF node this comparison will probably fail for the reasons I’ve described here.

Is your “Now CET” simply returning the current timestamp? If so, you could consider just using an expression of {{ $now }} instead of having another node for this (the docs on $now are here).

Thank you for the very useful {{$now}} tip !

Everything works fine now

1 Like

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