Siri Shortcuts: Calculating Dates Every X Days

I adjunct for the college I work at and am currently working on syllabi and course schedules. I am trying to create a workflow that calculates the dates every 7 days for a certain amount of weeks.

Here is my workflow: https://www.icloud.com/shortcuts/56d4da811f5640e6a852102f18cfa882

My issue is that I can technically get the right dates but I am not completely understanding the repeat function (lack of knowledge). This is the list that is produced for getting the date every 7 days for 4 weeks

  • Jan 8, 2019
  • Jan 15, 2019
  • Jan 8, 2019
  • Jan 15, 2019
  • Jan 22, 2019
  • Jan 8, 2019
  • Jan 15, 2019
  • Jan 22, 2019
  • Jan 29, 2019
  • Jan 8, 2019
  • Jan 15, 2019
  • Jan 22, 2019
  • Jan 29, 2019
  • Feb 5, 2019

As you can see, the repeat function is adding to the list each time so the list repeats itself. For the time being, I am running another workflow within this workflow that deletes duplicates for a list so technically I have something working but I would not like to clean up my workflow since I know I am misunderstanding repeats, lists, and variables.

Any help would be appreciated. Thanks!

The algorithm you were using was to build the list up, ut at the end the loop passes all iterations of that building to the next step - the split. Instead you just want to pass the final iteration into the split.

See if this revision makes sense and you can see what I did.

I know @sylumer has already answered, but here’s my try.
(in the spirit of learning new things)

https://www.icloud.com/shortcuts/f0f2b98937224efda304e897f71b8b1f

1 Like

This makes sense (wrapping my head around how I could have got to this place originally). My one question is the repeat index variable. What exactly does that mean?

On each iteration through the loop that’s a special inbuilt variable that holds the numeric value of that iteration.

On the first time through the repeat, repeat index = 1.
On the second time through the repeat, repeat index = 2.
On the third time through the repeat, repeat index = 3.

On the Nth time through the repeat, repeat index = N.

Does that make sense?

Ah, yes it does. That’s what I was slowly getting to but your explanation makes it clear. Thanks for your help.

Hey guys, almost off topic here, but possible a limitation for iOS 13 shortcuts: I couldn’t find a way to get a repeat action to iterate for X times, when X is a variable previously set on the workflow. Current implementation only allows me to use + and - buttons for adjusting iterations.

From what I got here that was the fix made by everyone in this topic (@brian_renshaw, @sylumer and @JKoopmans) alike.

Tap and hold the number for the repeat. Then you can select a variable.

2 Likes

Guess the haptic touch is here to stay!

Thanks, @RosemaryOrchard!