toISOString() error


I am using code node for formatting.

I have an incoming timestamp in the following payload

"Buy-from Vendor Name": "blah",
"Logistic Comp_ Order No_": "blah",
"Closed at Date": "2023-05-19T00:00:00.000Z",
"Closed by Entry No_": blah

I have noticed that Javascript by default will convert the date into the wrong format for what I need so I am using toISOString() to convert the time and maintain format of 2023-05-19T00:00:00.000Z

I am using the following item.json["Closed at Date"].toISOString()

It sometimes errors when running, sometimes it doesn’t date format of incoming data is always the same… Anyone have any insight? Error below:

ERROR: item.json.Closed at Date.toISOString is not a function [line 8]
TypeError: item.json.Closed at Date.toISOString is not a function
at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:8:99
at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:26:2
at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/bridge.js:485:11)
at (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/nodevm.js:426:23)
at Sandbox.runCodeAllItems (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/nodes/Code/Sandbox.ts:48:33)
at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/nodes/Code/Code.node.ts:89:28)
at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/src/Workflow.ts:1263:42)
at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/src/WorkflowExecute.ts:952:44
at processTicksAndRejections (node:internal/process/task_queues:96:5)


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