Check local time and delay execution

Hi everybody I want to have a workflow that sends an email to me, but I want it to only send the email if the time is within work hours.

So I want to delay the execution until say 8am If my triggers happen between let’s say 6 p.m. and 8 a.m.

Currently I have a wait node in place and it’s all working well for everything except delaying until 8am.

Is there a way to make the email node wait until that time if triggered before that time?

Information on your n8n setup

  • n8n version: 1.38.1
  • Running n8n via (Docker)
  • Operating system: Debian

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

First you have to define your working hours. Then you check against the current time.
You might run out of memory at some point, IDK.

instead of the loop, it might be better to calculate the delta to the next start.

To avoid running out of memory, I would have done it this way :

2 Likes

Why you don’t make a workflow executing every minute or hour and put a IF on the beginning to compare the current hour?

Like this:

This is because it’s being triggered by an event that can happen after hours, and I need it to wait until work hours to send that email. I can’t check if it’s happened in work hours, as it’s already gone and done during the night. If I understand you that is.

That is a nice solution. I’ll see what I can do with something along those lines. Thank you

remember to check for weekends :wink:

haha, good tip. But still, weekends during the day should be fine

Interesting. I added all my work days, but I am getting a false each time it runs. I see this, could it be the “Day of week” that’s causing the error, as I can’t see that anywhere. I am not great at this, and relatively beginer. I am sorry if this is something obvious.

Either your locale is different and if “Day of week” is “Montag” in german, or your native language you need to change the property names accordingly.

or if you have a different trigger node that does not have the property “Day of week” you need to get that property elsewhere.

Instead of “day of week” you could use something like $now.weekdayLong().

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