Need help with expression {{ DateTime.local($json["created_at"]).toISODate() }}

I am getting a date in the long format 2022-11-14T00:00:00.000-03:00

I would like to convert the date to short format: 2022-11-14 or 2022/11/14 or 20221114.

In my If node howewer, I get the return [Object: null]

The formula I wrote must be wrong, but how?

  • n8n version: 0.217.02
  • Database you’re using (default: SQLite): postgres
  • **Running n8n with the execution process [own(default), main]:**main
  • **Running n8n via [Docker, npm, n8n.cloud, desktop app]:**docker

I found an easier formula in How to format date like this? - #2 by MutedJam : {{ $today.toFormat(‘yyyy-MM-dd’) }}

{ "meta": { "instanceId": "a4b9e677d0d9dc86afed299cb786a300c8a6e0ca557cb566a00de2a436814b34" }, "nodes": [ { "parameters": { "values": { "string": [ { "name": "today", "value": "={{ $today.toFormat('yyyy-MM-dd') }}" } ] }, "options": {} }, "name": "Set1", "type": "n8n-nodes-base.set", "typeVersion": 1, "position": [ 6020, 1700 ], "id": "c6b51d9f-35c2-4704-9934-d2dad20e8031" } ], "connections": {} }

2 Likes

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