Best answer

does this date delay/lookup feature exist in Zapier

  • 5 December 2022
  • 7 replies
  • 85 views

Userlevel 1
Badge

Hey everyone, I have a webinar event that happens at the first Wednesday of every month. I am looking to see if there is a way Zapier could you could give me the exact date of the first Wednesday of the upcoming month.

Example: If I register for the event today, then I would like zapier to give me the output as 04/01/2023 because that is the First Wednesday of the upcoming month January.

If this doesn’t exist, then I would like to delay until the first Wednesday of every month. It would be great if you guys could let me know if this is possible or not.

 

icon

Best answer by GetUWired 6 December 2022, 14:40

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

7 replies

Userlevel 7
Badge +14

Hi @Fahad.S 

Good question.

You may have to use a custom Code step to determine the next X date.

Userlevel 1
Badge

Hi @Fahad.S 

Good question.

You may have to use a custom Code step to determine the next X date.

Hi @Troy Tessalone,

Good answer.

 Do you happen to know what the code would look like or how where and how I can search for such codes

Userlevel 7
Badge +14

@Fahad.S 

GSearches on the topic usually leads to results of code that can be copied/modified.

Userlevel 7
Badge +12

Hi @Fahad.S,

Zapier’s date inputs are extremely robust. In my experience, you can just put something like “first wednesday next month” into a delay step. 

 

 

Userlevel 7
Badge +14

@Fahad.S

cc: @GetUWired 

Make sure to keep this limit in mind when using the Delay app:

The maximum time a task can be held for is for one month (31 days).
Since tasks will be queued, the maximum number of tasks in the queue depends on the Time Delayed For (value) value.
For example, if you set the delay to one day, the maximum number of tasks in the queue will be 31.
If a 32nd task is created within that period, it will error on the delay step because the scheduled time it will be released is too far away.

 

You may have to use 2 Delay steps in the Zap:

Delay until the first of the upcoming month

Then Delay until the first wednesday, but again there’s a chance the first Wednesday is the first of the month.

So the logic can get a bit tricky.

Userlevel 1
Badge

@Fahad.S

You may have to use 2 Delay steps in the Zap:

Delay until the first of the upcoming month

Then Delay until the first wednesday, but again there’s a chance the first Wednesday is the first of the month.

So the logic can get a bit tricky.

 

I agree with @Troy Tessalone.

Hi @Fahad.S,

Zapier’s date inputs are extremely robust. In my experience, you can just put something like “first wednesday next month” into a delay step. 


What if the person joins on January 1st 2023, Zapier will bring in the date for next month of Wednesdays according to the delay “first wednesday next month”

@Troy Tessalone , @GetUWired, This is what I am thinking of adding “first Wednesday of this or next month whichever is the earliest”.

What do you guys think can be done to solve this problem.

Userlevel 7
Badge +12

@Fahad.S 

In that instance, yes, code will be your best bet. Try the below

 

let delay_till;
let days_til_wednesday, nextWednesday, nextMonth, year;
let days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]

let today = new Date(inputData.today)
let day_of_week = today.getDay();
let day_of_month = today.getDate();

if (day_of_week === 3 && day_of_month <= 7) {
//today is the first wednesday of the month
delay_till = today;
} else if (day_of_week < 3 && day_of_month <= 7) {
//this might be the next upcoming wednesday if the next wednesday is not the 8th.
//calculate days until wednesday and set tentative release date
days_til_wednesday = 3 - day_of_week;
nextWednesday = new Date(today)
nextWednesday = new Date(nextWednesday.setDate(nextWednesday.getDate() + days_til_wednesday));
delay_till = nextWednesday;

if (nextWednesday.getDate() === 8) {
//this is not the first wednesday of this month. delay until first wednesday of next month.
nextMonth = today.getMonth() + 2;
year = today.getFullYear()
if (nextMonth == 13) {
//next month is january of next year.
nextMonth = 1;
year = today.getFullYear() + 1
}

let firstOfMonth = new Date(`${nextMonth}/1/${year}`)
let firstOfMonth_dow = firstOfMonth.getDay();

if (firstOfMonth_dow === 3) {
//first of next month is wednesday
delay_till = firstOfMonth;
} else if (firstOfMonth_dow < 3) {
//first of next month is before wednesday
days_til_wednesday = 3 - firstOfMonth_dow;
nextWednesday = new Date(firstOfMonth)
nextWednesday = new Date(nextWednesday.setDate(nextWednesday.getDate() + days_til_wednesday));
delay_till = nextWednesday;
} else {
//first of next month is after a wednesday
days_til_wednesday = 10 - firstOfMonth_dow;
nextWednesday = new Date(firstOfMonth)
nextWednesday = new Date(nextWednesday.setDate(nextWednesday.getDate() + days_til_wednesday));
delay_till = nextWednesday;
}
}
} else {
//we have already past the first wednesday
//this is not the first wednesday of this month. delay until first wednesday of next month.
nextMonth = today.getMonth() + 2;
year = today.getFullYear()
if (nextMonth == 13) {
//next month is january of next year.
nextMonth = 1;
year = today.getFullYear() + 1
}

let firstOfMonth = new Date(`${nextMonth}/1/${year}`)
let firstOfMonth_dow = firstOfMonth.getDay();

if (firstOfMonth_dow === 3) {
//first of next month is wednesday
delay_till = firstOfMonth;
} else if (firstOfMonth_dow < 3) {
//first of next month is before wednesday
days_til_wednesday = 3 - firstOfMonth_dow;
nextWednesday = new Date(firstOfMonth)
nextWednesday = new Date(nextWednesday.setDate(nextWednesday.getDate() + days_til_wednesday));
delay_till = nextWednesday;
} else {
//first of next month is after a wednesday
days_til_wednesday = 10 - firstOfMonth_dow;
nextWednesday = new Date(firstOfMonth)
nextWednesday = new Date(nextWednesday.setDate(nextWednesday.getDate() + days_til_wednesday));
delay_till = nextWednesday;
}

}




return { today: today.toDateString(), day_of_week: days[day_of_week], day_of_month: day_of_month, delay_till: delay_till.toDateString() }

As a troy mentioned there may be some rare scenarios where Zapier has to delay longer than is allowed. To be safe, you can break your Zap into multiple zaps and use Airtable for longer delays.
 

 
The above related article references using either Google Calendar or Airtable to create delays longer than 30 days. Airtable is my preferred method since with Google Calendar you may have to scrape information out of the event details or something but with Airtable you can create individual fields for information you might need when Zapier triggers again.