I have 7 different dates in format MM/DD/YYYY. But I need another format DD.MM.YYYY. I want to change format in Set node because I don’t want my workflow to be bulky with 7 Date & Time nodes. But I get this issue:
Also I have to delete expressions with date < 01.01.1900. Maybe I can do both tasks with Code node, but Im pretty bad with JavaScript. Maybe You can help me?
In an n8n expression (and JavaScript in general), the single quotes ' would indicate the beginning and end of a string. So in an expression like DateTime.fromFormat('$json["PM clinic"]', 'L/d/yyyy'). n8n would try to parse a string of $json["PM clinic"] which fails.
If you don’t use the quotes, n8n would parse the value of your PM clinic field instead. Here’s an example workflow showing this:
As for your second question, deleting dates before 1900, can you confirm what exactly you want to delete? Do you want to remove the entire item or just the specific value?
In this case I think the easiest approach would be to first parse the date, then use the IF node to check if it was before 1990. Here’s an example, filtering the Bucket Inspection field (you can of course change this and add more conditions for additional fields as needed):
You can see that only the item with a Bucket Inspection date after 1990 would pass the IF node here: