If today is 5/8/2020, how will I get the value 2020-05-15 from the drop down? Please note that hardcoding is not an option. This is for a payroll automation so the date changes and I need to get the nearest cutoff value from the drop down.
From the drop-down list values, we can learned that the dates are consistent and have a predictable pattern.
Each month has two dates. 15th of the month and last day of month
There are a total of 24 values to choose for each year
Before we proceed further, may I know if you need to process 2020 payroll in year 2021? Will you still see 2020-12-15, 2020-12-31, 2021-01-15, 2021-01-31, etc… ?
@caduque I guess if the Condition is to Select the date Depends on Current Date Value, Then using an if Condition, we can Check if the Current date is less than 15th Date and then Assign the value 2020-05-15, if the Current Date Value is greater than 15th date then you can Assign the value 2020-05-31 or the Last Date of the Month. If this is the Logic you’re expecting then we can make the Date’s dynamic by using a DateTime Initialisation
@caduque Create a Variable with DateTime Type, then in the Then Block of if Condition you can Assign it with the below value :
varDate = new DateTime(now.Year,now.Month,15)
In the Else Block you can Assign the below expression :
varDate =new DateTime(now.year,now.month,DateTime.DaysInMonth(now.Year,now.Month))
Could open UiPath Studio and start the UI Explorer. Indicate on Screen, press F2 to pause for a few seconds, which will allow you to click on the drop-down list, wait… till the count down is over, click on the first value (2020-01-15) in the drop-down list. Screenshot the UI Explorer. Repeat the steps but click the second value (2020-01-31) in the drop-down list. Screenshot the UI Explorer.
Post it for comparison. We need to examine the selector attributes and values.
@caduque You’ll need to change the Condition to this Expression :
Firstly Create Four variables of DateTime Type, say DateFor26, DateFor10, DateFor11 and DateFor25.
Initialise the four variables with below expression using Assign Activity as below :
DateFor26 = new DateTime(Now.Year,Now.AddMonths(-1).Month,26)
DateFor10 = new DateTime(Now.Year,Now.Month,10)
DateFor11 = new DateTime(Now.Year,Now.Month,11)
DateFor25 = new DateTime(Now.Year,Now.Month,25)
In the If Activity use this Condition :
DateFor26 <= Now.Date <= DateFor10
in then Then block you can assign another datTime variable, say varDate in this way :
varDate = new DateTime(now.Year,now.Month,15)
You can use an Other if Activity with Condition :
DateFor11 <= Now.Date <= DateFor25
in then Then block you can assign varDate in this way :
varDate =new DateTime(now.year,now.month,DateTime.DaysInMonth(now.Year,now.Month))
Note : I am using an Another If Condition Since you have not Specified what to do if the date Falls on 26th to 31st of the Current Month. Instead of Another If Condition you can use second varDate Expression inside the Else Block of the First If Activity, if you’re sure that the 26th to 31st of Current Month Condition never arises.
@caduque In the Steps that i mentioned above change the Expression of DateFor25 as follows :
DateFor25 = new DateTime(Now.Year,Now.AddMonths(1).Month,25)
I think you are able to understand why i am doing it.
or the Alternate Would be to do what was in the Note, as to just use One if Activity with else block and there would be no need for the variables DateFor11 and DateFor25.
My Apologies if it’s confusing , Just go ahead and Implement the Steps that I have Provided and check if it works.