I’m having an issue with DateTime.FromISO
. When I run each step of the process manually, it converts correctly, but when I run the entire workflow, it says the date is invalid.
Information on your n8n setup
- n8n version: 1.60.1
- Database (default: SQLite): SQLite
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
- Operating system: Windows 11
Welcome to the community @Diego_Araujo !
Tip for sharing information
Pasting your n8n workflow
Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </>
(preformatted text) in the editor and pasting in your workflow.
```
<your workflow>
```
That implies to any JSON output you would like to share with us.
There is no need in specifying the timezone as an argument to from ISO()
as the timezone itself is already presented in the string. If you remove that part and leave only DateTime.fromISO($json["datePoint"])...
, will it make any difference for you?
One more exercise. If you leave only DateTime.fromISO($json["datePoint"])
with no further chaining will you get something like [DateTime: 2024-09-09T19:45:17.000-04:00]
in the UI (just below the expression)? That would indicate that the DateTime object is valid.
Having said the above I believe that the string is likely not properly formatted in datePoint
. For example, if you have an extra space as in "2024-09-09T23:45:17.000Z " (extra space at the end), you will get the same “Invalid DateTime” error.
Could you check in JSON view how the date string in datePoint
looks like?
I tried the suggestions, but it still seems to be returning an “Invalid DateTime” error. If you look at the image, the preview of the conversion shows correctly, and the JSON has no spaces. I use this database in a continuous monitoring application, so if there were any issues with the JSON, they would have appeared earlier. The strangest part is that if I rerun just this step, the error doesn’t show up.
my workflow:
Below are the pictures: one of the workflow running for the first time, and in the next image, when I rerun just the date transformation step.