Hey Community,
in a previous project using another automation platform we had tons of workflows that were scheduled to run regularly, but with date restrictions. For example “run only on working days” would require not only to exclude weekende, but also national holidays. Other restrictions could be “first working day of the month”, or “last working day of the quarter”.
Is there a way to achieve this in n8n out of the box? I could not find any information about that…
So, before i start building it myself - am i missing something?
Hi @Martin.Markwart ,
If I get you correctly, you aren’t missing anything. I don’t think n8n has built in scheduling options for national holidays, “first working day,” or similar complex date like this.
However, you can try building these complex scheduling rules using n8n’s other powerful nodes.
I think it’s possible using Custom (Cron) with expressions, not easy for everyone (let AI write it), but it should be doable,
For example:
Hi @Martin.Markwart,
There is no complex scheduling for checking public holidays, so you’ll need to build some custom checks in.
To get started you can use the cron expression below to run at 9:00 AM for example on days 1 to 7 of every month, but only on weekdays (Monday-Friday). This effectively captures the first working day of each month, as the first weekday will always fall within the first 7 days.
0 0 9 1-7 * 1-5
Then from here you can now have a code node to do the more complex checks whether the date is falling on a pre-defined list of public holidays whether hard coded or from a http rest call to a service returning public holidays and then use an IF node to check if true then execute, else do nothing.
I can help give you an example of the code node logic to give you an idea of what this could look like.
Thank you for your comments!
It is not a problem i currently have to solve, i just wanted to know if there is such a feature in n8n. As i said, in a past project this was used very extensively - we are talking about hundreds of workflows using dozens of calendar restrictions in various combinations. I know about the cron workarounds, but that would obviously not be a feasible solution for such a scenario..
I think, i will build a template for this…this could be useful.
You can maybe also check the community nodes for something which caters for more complex schedulers. Or maybe that would be a nice project to build a custom node for complex rules like date exclusions etc.
Ok, i played around yesterday evening and got it to work using data tables as backend - but it’s not pretty as data tables are quite limited in terms of query logic. I think i will build this with a proper database backend…
That’s great news! I would highly recommend Supabase