Issues converting to DateTime during workflow execution but works during when manually executing Node

Describe the problem/error/question

I’m having similar issues to Fails on automated execution but works manually - Questions - n8n and their workaround has been able to get me up and running.

I have a code node that converts the whenCreated time from an LDAP node into a new Date, when using this date within an If node it fails when executing the workflow with this error.

When executing the node manually it works correctly.

It seems to be changing the dateTime during the workflow execution, but not during individual node execution.

Like the above post I was able to work around using this expression

 {{ new Date($json['created'].toString()).toISOString() }}

Has anyone else run into this? It’s tripped me up a few times now dealing with the various date formats that LDAP/AD seems to like to use.

What is the error message (if any)?

NodeOperationError: The provided value 1 'Mon Jun 24 2019 12:22:41 GMT+0000 (Coordinated Universal Time)' in condition 1 is not of the expected type 'dateTime' [item 0]
    at extractValue (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/ExtractValue.js:134:15)
    at getNodeParameter (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/NodeExecuteFunctions.js:1451:54)
    at Object.getNodeParameter (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/NodeExecuteFunctions.js:2090:24)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/If/V2/IfV2.node.js:68:33
    at Array.forEach (<anonymous>)
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/If/V2/IfV2.node.js:63:29)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:696:42)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:656:68

Please share your workflow

Share the output returned by the last node

    "dn": "snip",
    "whenCreated": "20190624122241.0Z",
    "userAccountControl": "snip",
    "accountExpires": "snip",
    "sAMAccountName": "snip",
    "userPrincipalName": "snip",
    "description": [],
    "lastLogonTimestamp": null,
    "enabled": true,
    "lastLogon": null,
    "formattedDate": null,
    "created": "2019-06-24T12:22:41.000Z"

Information on your n8n setup

  • n8n version: 1.21.1
  • Database (default: SQLite): PostgreSQL 16
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu 22.04.3

Hey @SomeGen,

It looks like you have found the best sort of workaround for it, Dates can be tricky sometimes and I know we try to make them easier to work with but we don’t always get it right. I am a big fan of always doing the expression you are using to make sure that the date is formatted and it is possibly something we could automatically do but I think it would cause more issues.

Did you try setting the “less strict validation” option the first error mentioned as well to see if that helps?

1 Like