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…
you can use for each activity and write into List of items something like this
Enumerable.Range(Cint(Datetime.ParseExact(startMonth ,“MMMM”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM”)),Cint(Datetime.ParseExact(endMonth ,“MMMM”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM”)))
then in loop use if which checks your currentItem has length smaller than 2
Friend, excuse me, can you please send me the entire project of this example that you are dealing with, I tried to see the file that you attached but I get these errors and from here to when I fixed them it takes a long time…
list of items:
Enumerable.Range(Cint(Datetime.ParseExact(startMonth ,“MMMM”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM”)),Cint(Datetime.ParseExact(endMonth ,“MMMM”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM”)))
Log message in then
Datetime.ParseExact(“0”+currentItem.ToString ,“MM”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MMMM”)
Log message in else
Datetime.ParseExact(currentItem.ToString ,“MM”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MMMM”)
It works as an idea, however it is not what I need because the initial and final months are entered manually by the user and there are months from the indicated initial to the indicated end.
Just assign your months to vars: startMonth and endMonth and it will print month range. It may have problem when for example:
Start month is November and end month is January.