ERROR: The date input format could not be recognized

Hi,
I get error when i tried to format a date from 2021-12-06T00:00:00.000Z to YYYY-MM-DD.
Please see image below.

and there is my workflow

and how can i “format a date” for multiple column in my workflow?

Thank you

  • n8n version: 0.194.0
  • Database you’re using (default: SQLite): MS SQL to MYSQL
  • Running n8n with the execution process [own(default), main]: Own
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Hey @rusdiaman,

Do all 100 items from Microsoft SQL have a date set? Doing a quick test with that date and the output format shows it does work so the only thing I can think of at the moment is one of the dates in input items is either missing or in a different format.

Hi @Jon
Not at all. there are some blank data. if that happens, how do I apply that format to date?

is there a way to apply format to date for multiple columns?

Thank you for your quick respons.

Hey @rusdiaman,

The first thing to do would be to add an if node and only try to format the date if the date field is not empty.

If it is empty you could then send an alert or use a default date.

For multiple date columns you can use multiple date and time nodes or use a set node and an expression using Luxon.

https://docs.n8n.io/code-examples/expressions/luxon/

Hi @Jon ,
i have try to use if node and only format the date if the date fields is not empty. and its work perfectly.

but when i try to convert multiple date and time with set node (using luxon) i get the error like below.

can you tell my how i can do that?
i try to write in value like this
DateTime.fromISO({{$json[“SolveDate”]}})

i think something wrong about that. Please help

Thank you for your time, @Jon

Hey @rusdiaman,

Have you tried {{ DateTime.fromISO($json["SolveDate"]) }}? Anything between {{ }} is ran as javascript.

yes, i have tried it. the result like below.

but i want to try convert date and time to format “YYYY-MM-DD hh:mm:ss” like requestdate column.
how i can do that?

Hi @rusdiaman,

In Luxon documentation you can find all the variables to format any date.

In the case you mention, have you tried with {{ DateTime.fromISO($json["SolveDate"]).toFormat('y-LL-dd HH:mm:ss')}} ?

image

:wink:

1 Like

Hi @martinhache ,

Its work perfectly.
Thank you for your time.

1 Like

Great! :+1: