Generate 20 Radom Dates from last 14 days

Hello all,

How can I generate 20 random dates from last 14 days of current date?

Any solution?

Thanks in advance.

Hi there,

There’s a few ways to do this here’s one solution for you:

Backend:

  1. Go to your backend workflows and create a new api workflow

  2. Call it like: generate_random_dates and set one parameter to key: counter and type: number

  3. Download random number generator plugin and set the number to -1 → -14
    image

  4. Create a new thing in your DB for this example I created a data type data and created a field to be a list of dates. Here you want to add the following:
    Current date/time +days: Result step 1 random number generator
    image

  5. Make it recursive:
    Schedule the same API workflow and use the parameter + 1 to add to the count parameter then under only when choose “counter < 20” (It will run 20 times then stop)
    image

After this then go to the frontend and do the following:

Frontend:

  1. Set up a button on your page to generate the dates
  2. Schedule the API workflow and set the count to 1

I then set a repeating group up for this example and this is what I got:

Hope that helps!

Look like it will work for me.

I will implement this logic and will let you know.

Thanks @tom18

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.