Print months from an start month to an entered end month

Hello everyone, I am making an automation where the user is asked to enter a starting month and an ending month according to a list of options, after that what I need is to print the months that are in the entered range on the screen. For example, if you enter January as the starting month and May as the ending month, I need it to print January, February, March, April, and May…

Does anyone have an idea on how to do it?

I attach the example file that I am making but it does not work as I think…

Main.xaml (21.6 KB)

@Melanny_Herrera_Cruz
Hi please follow these steps.
1)
convert your start month and end month to month numbers. like
Jan → 1
May ->5

Assign input_month = “August”
Assign input_month = Datetime.ParseExact(input_month ,“MMMM”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM”)

put loop over end_month_number >=Start_month_number and decreament each time.

inside loop use this expression

DateTime.Now.AddMonths(-YourLoopVar) .ToString(“MMM”)

Define variables:

image

Assign values for test:

image

Loop and print values:

Output:
image

Hi Paul, thanks for your help. However, can you please tell me how to finish the validation because what was done as indicated but after detecting the last month the process continues infinitely…

Take the Assign out of the If. It has to be after the If so it’s processed every time. The way you have it, the counter is only incremented if the Month is output. You need the counter incremented every time through the loop. And you don’t need anything in the Else block.

Also, you have used a While. I used a Do While. They are different, although in this case it shouldn’t matter which you use.

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