Error in working with DateTime.fromISO()

Describe the problem/error/question

Error in working with DateTime.fromISO()

Getting data from NocoDB and PosrtgreSQL.
The dates are compared in the IF node.
For NocoDB {{ DateTime.fromSQL($json.DateTimeAction) }} works as expected,

For PostgreSQL {{ DateTime.fromISO($json[“lastPublishedDate”]) }} }} gives the error ERROR: The provided value 1 ‘Invalid DateTime’ in condition 1 cannot be converted to the expected type ‘dateTime’ [item 0].

Not only in the IF node, but also in Filter.

Translated with DeepL.com (free version)

What is the error message (if any)?

ERROR: The provided value 1 ‘Invalid DateTime’ in condition 1 cannot be converted to the expected type ‘dateTime’ [item 0]

Try to change the operator, or change the type with an expression

Details

Time

13.02.2024, 10:57:50

Stack

NodeOperationError: The provided value 1 'Invalid DateTime' in condition 1 cannot be converted to the expected type 'dateTime' [item 0]
    at extractValue (/app/code/node_modules/n8n-core/src/ExtractValue.ts:205:9)
    at getNodeParameter (/app/code/node_modules/n8n-core/src/NodeExecuteFunctions.ts:2305:28)
    at Object.getNodeParameter (/app/code/node_modules/n8n-core/src/NodeExecuteFunctions.ts:3457:12)
    at /app/code/node_modules/n8n-nodes-base/nodes/If/V2/IfV2.node.ts:77:18
    at Array.forEach (<anonymous>)
    at Object.execute (/app/code/node_modules/n8n-nodes-base/nodes/If/V2/IfV2.node.ts:69:23)
    at Workflow.runNode (/app/code/node_modules/n8n-workflow/src/Workflow.ts:1324:31)
    at /app/code/node_modules/n8n-core/src/WorkflowExecute.ts:1046:44
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at /app/code/node_modules/n8n-core/src/WorkflowExecute.ts:1722:11

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • **n8n version:Version 1.26.0
  • **Database (default: SQLite):PostgreSQL
  • **n8n EXECUTIONS_PROCESS setting (default: own, main):main
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):Docker
  • **Operating system:Ubuntu

hello @asuhan

If you disable the “Return All” button in the Postgres node and receive only a small portion of the results, would be the error the same? If so, can you please attach the sample of data to check?

The expression looks fine.

Good afternoon. I limited it to 10 records, the error persists. At the same time, if you run the whole process, the error is there. If you go to the IF node after that and click Test Step there, everything is processed.
This was also described in the topic

[
  {
    "work_done": 0,
    "counter": 0,
    "lastPublishedDate": "2024-02-15T21:00:00.000Z"
  },
  {
    "work_done": 0,
    "counter": 0,
    "lastPublishedDate": "2024-02-15T21:00:00.000Z"
  },
  {
    "work_done": 0,
    "counter": 0,
    "lastPublishedDate": "2024-02-01T21:00:00.000Z"
  },
  {
    "work_done": 0,
    "counter": 0,
    "lastPublishedDate": "2024-02-12T21:00:00.000Z"
  },
  {
    "work_done": 0,
    "counter": 0,
    "lastPublishedDate": "2024-02-15T21:00:00.000Z"
  },
  {
    "work_done": 0,
    "counter": 0,
    "lastPublishedDate": "2023-12-20T21:00:00.000Z"
  },
  {
    "work_done": 0,
    "counter": 0,
    "lastPublishedDate": "2024-02-12T21:00:00.000Z"
  },
  {
    "work_done": 0,
    "counter": 0,
    "lastPublishedDate": "2024-02-14T21:00:00.000Z"
  },
  {
    "work_done": 0,
    "counter": 0,
    "lastPublishedDate": "2024-02-11T21:00:00.000Z"
  },
  {
    "work_done": 0,
    "counter": 0,
    "lastPublishedDate": "2024-02-12T21:00:00.000Z"
  }
]

Yes, seems like a bug. And it can’t be reproduced with pinned data. So to reproduce it, there should be set a PostgresDB. You can avoid the issue if you place the Code node right after the Postgres Node which will output the same.

1 Like

Thank you. Adding the Code node helped, but it looks kind of weird. :grinning:

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