Postgres Node Datetime Output Type Mismatch

Hi,

I found some unexpected behavior that seems like it might be a bug, possibly related to Error in working with DateTime.fromISO().

During a full flow execution, the Postgres:select node seems to output “date” type values as DateTime objects, and at other times, they’re strings.

In screenshot #1, a full flow execution containing a Set Node, the “First Seen” value expression uses the $json[…].format(…) coming directly from the Postgres Node. Even though the editor preview shows “Invalid DateTime”, during execution, the output is set properly in yyyy-MM-dd format. (notice that the second property “Last Seen” which uses DateTime.fromISO(…) behaves oppositely: it displays correctly in the editor preview but the node output says “Invalid DateTime”)

Then, in screenshot #2 the opposite happens. It’s the same Set Node parameters and input, but executed with the “Test Step” button instead of “Execute workflow”. Notice that the editor preview and output for that field both show invalid. And the second field “Last Seen” is now valid and outputs the correct value.

It seems like there’s a mismatch between the editor UI and actual node execution reading the input fields as strings or DateTime objects.

Let me know if any other info would be helpful or if I’m missing something.

Thanks!

DB schema for reference:
image

Node config:

Information on your n8n setup

  • n8n version: 1.27.2
  • Database (default: SQLite): n/a
  • n8n EXECUTIONS_PROCESS setting (default: own, main): n/a
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: windows

hello @jzrts

Where did you get the format method? n8n handles dates between nodes as strings, so the format method may not work properly. For dates, the best way is to use the DateTime.toFormat method, Luxon doesn’t have the format method

1 Like

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