Skip to main content
Question

Why doesn't my Zap select random days when it runs on Monday?

  • February 10, 2025
  • 5 replies
  • 47 views

I have a zap that it needs to select two random days of the week and send messages to slack channel. And it’s scheduled to run every Monday morning. Why doesn't it select days when it runs on Monday morning? I have to manually run the second part with code so that it selects days.
 

 

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

5 replies

aslamsaheer
Forum|alt.badge.img
  • New
  • February 10, 2025

Have you tried using Formatter>Number>Random Number to generate day like in 0-6. Then in next step use Delay>Delay Until> After <previous output> days. Then send the required message.


Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • February 11, 2025

Hi ​@zappier_ss 

For us to have more info, post screenshots with how your Zap steps are configured in EDIT mode with the field mappings visible.

 

Check your Zapier account time zone and your Zap time zone.

Help: https://help.zapier.com/hc/en-us/articles/8496215472653-Zap-dates-or-times-are-incorrect


SamB
Community Manager
Forum|alt.badge.img+11
  • Community Manager
  • February 14, 2025

Hi there, ​@zappier_ss! 👋

Have you had a chance to give aslamsaheer’s suggestion a try yet? And if so, did it work as hoped?

If not, can you share some screenshots of the Configure section of each of the Zap steps, as Troy mentioned, so we can take a closer look at what might be preventing it from randomly selecting the days? Make sure to blur or remove all personal information (names, emails, addresses etc.) from screenshots before sharing - you can use a tool like Zappy for that.

Looking forward to hearing from you! 


  • Author
  • Beginner
  • March 7, 2025

 

This post has been edited by a moderator to remove personally identifiable information (PII). Please remember that this is a public forum and avoid sharing sensitive details.


SamB
Community Manager
Forum|alt.badge.img+11
  • Community Manager
  • March 10, 2025

Thanks for sharing those screenshots ​@zappier_ss. I can’t see the full code that’s being used to pick the random date so I can’t see if there’s an issue with the code that’s preventing it from running. But it looks like it’s calculating the difference between two dates, is that right? I wonder if that might be causing the trouble. 🤔 

I tested with some code that just gets the current date then picks a date at random within the next 7 days and that seems to work ok:

// Get the current date
const currentDate = new Date();

// Generate a random number between 1 and 7
const randomDays = Math.floor(Math.random() * 7) + 1;

// Calculate the future date by adding the random number of days
const futureDate = new Date(currentDate);
futureDate.setDate(currentDate.getDate() + randomDays);

// Format the future date to a readable string (ISO format)
output = { randomDate: futureDate.toISOString().split('T')[0] }; // YYYY-MM-DD format

5f9781873eace661d2bd8cbc6fd89490.png
Could you give that a try sort of approach a try and let me know if that works any better?