"ERROR: The value "undefined" is not a valid DateTime."

Any ideas on this error appearing on my IF node?

Operation: IF date1 is after date2, and if date1 is before date3, THEN…

All of the dates input are formatted the same, so I’m not sure what I’m missing. All the values have been filled in.

Hey @ed.harding,

Welcome to the community :sparkling_heart:

Can you share some more details? From which node the IF node is fetching the data? How are you referencing the values? It would be helpful if you can share your workflow, and the output that you’re using in your workflow. Please replace any sensitive data with dummy data :slight_smile:

Hey @ed.harding,

Did you resolve the issue? Please feel free to let us know if you need help :slight_smile:

All resolved thanks! I’d missed something small

That’s great to hear! Can you share what did you miss? This would help someone with a similar issue to find solution faster :slight_smile:

WHAT IS WRONG?

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        -400,
        300
      ]
    },
    {
      "parameters": {
        "url": "http://www.obcp.es/monitor/observatorio-de-recursos-contractuales",
        "allowUnauthorizedCerts": true,
        "responseFormat": "string",
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        -40,
        300
      ]
    },
    {
      "parameters": {
        "extractionValues": {
          "values": [
            {
              "key": "link",
              "cssSelector": "a",
              "returnValue": "attribute",
              "attribute": "href",
              "returnArray": true
            }
          ]
        },
        "options": {}
      },
      "name": "HTML Extract",
      "type": "n8n-nodes-base.htmlExtract",
      "typeVersion": 1,
      "position": [
        120,
        300
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "link",
        "options": {}
      },
      "name": "Item Lists",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        300,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"link\"]}}",
              "operation": "regex",
              "value2": "\\/monitor/"
            },
            {
              "value1": "={{$json[\"link\"]}}",
              "operation": "notContains",
              "value2": "observatorio"
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        480,
        300
      ]
    },
    {
      "parameters": {
        "url": "=http://www.obcp.es/{{$json[\"link\"]}}",
        "allowUnauthorizedCerts": true,
        "responseFormat": "string",
        "options": {}
      },
      "name": "HTTP Request1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        660,
        280
      ]
    },
    {
      "parameters": {
        "extractionValues": {
          "values": [
            {
              "key": "titulo",
              "cssSelector": ".block-entity-fieldnodetitle > span:nth-child(1)",
              "returnArray": true
            },
            {
              "key": "Fecha",
              "cssSelector": "section.block-ctools-block:nth-child(3) > span:nth-child(1)",
              "returnArray": true
            },
            {
              "key": "Parrafo",
              "cssSelector": "p",
              "returnArray": true
            }
          ]
        },
        "options": {}
      },
      "name": "HTML Extract1",
      "type": "n8n-nodes-base.htmlExtract",
      "typeVersion": 1,
      "position": [
        840,
        280
      ]
    },
    {
      "parameters": {
        "functionCode": "// Code here will run once per input item.\n// More info and help: https://docs.n8n.io/nodes/n8n-nodes-base.functionItem\n\nDateParts = $json[\"Fecha\"][0].split(\"/\");\n\nobj= new Date(+DateParts[2], DateParts[1] - 1, +DateParts[0]).setUTCHours(\n      0,\n      0,\n      0,\n      0\n    )\nvar date = new Date(obj)\n// Add a new field called 'myNewField' to the JSON of the item\nitem.FechaParse = date;\n\n// You can write logs to the browser console\nconsole.log('Done!');\n\nreturn item;"
      },
      "name": "FunctionItem",
      "type": "n8n-nodes-base.functionItem",
      "typeVersion": 1,
      "position": [
        1000,
        280
      ]
    },
    {
      "parameters": {
        "functionCode": "// Code here will run only once, no matter how many input items there are.\n// More info and help: https://docs.n8n.io/nodes/n8n-nodes-base.function\n// Get the global workflow static data\n//const staticData = getWorkflowStaticData('global');\n// Get the static data of the node\nconst staticData = getWorkflowStaticData('node');\n\n// Access its data\nconst lastExecution = staticData.lastExecution;\n\n// Update its data\nstaticData.lastExecution = new Date().getTime();\n\nvar date = new Date(staticData.lastExecution)\n// Loop over inputs and add a new field called 'myNewField' to the JSON of each one\nfor (item of items) {\n  item.json.myNewField = date;\n}\n// Delete data\ndelete staticData.lastExecution;\n// You can write logs to the browser console\nconsole.log('Done!');\n\nreturn items;"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        -260,
        320
      ]
    },
    {
      "parameters": {},
      "name": "NoOp",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1720,
        380
      ]
    },
    {
      "parameters": {
        "conditions": {
          "dateTime": [
            {
              "value1": "={{$node[\"Date & Time\"].json[\"data\"]}}",
              "operation": "before",
              "value2": "={{$json[\"data\"]}}"
            }
          ]
        }
      },
      "name": "IF1",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1380,
        280
      ]
    },
    {
      "parameters": {
        "value": "={{$json[\"myNewField\"]}}",
        "options": {}
      },
      "name": "Date & Time",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 1,
      "position": [
        -120,
        20
      ]
    },
    {
      "parameters": {
        "value": "={{$json[\"FechaParse\"]}}",
        "options": {}
      },
      "name": "Date & Time1",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 1,
      "position": [
        1160,
        280
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "HTML Extract",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML Extract": {
      "main": [
        [
          {
            "node": "Item Lists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Item Lists": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "HTML Extract1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML Extract1": {
      "main": [
        [
          {
            "node": "FunctionItem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FunctionItem": {
      "main": [
        [
          {
            "node": "Date & Time1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Date & Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF1": {
      "main": [
        null,
        [
          {
            "node": "NoOp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time1": {
      "main": [
        [
          {
            "node": "IF1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

@Cristobal_Moya anymore context to that one? Do you get a specific error message?