How can calculate add 20 Days to today date?

How can ii add 20 Days to today? Or how can i calculate the difference between a date and today? I need to verify if a date is 20 days or longer than today…

Welcome to the community @Tbiyss!

That is actually more a JavaScript question and less n8n related. So you should easily find an answer if you do a Google search.

Anyway here very fast the basics:

new Date().getTime(); // Now in epoch milliseconds
new Date().getTime()+(20*24*60*60*1000); // In 20 days in epoch milliseconds
new Date('2020-08-01').getTime(); // The 1st of August in epoch milliseconds

You can use the above in an IF-Node and it will then route accordingly.

2 Likes

I was trying to use setDate but I got an error the function does not exist. That was the route google put me on :slightly_smiling_face:

Thanks for support

have you found the answer?

It’s now much more simple with Luxon which is included in recent n8n versions:

https://docs.n8n.io/code-examples/expressions/luxon/#get-n-days-from-today

2 Likes

Thanks @pemontto
I totally missed this. Is gonna make things a lot easier for me. :+1:

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