Getting the cutoff value


I have these values inside a drop down.


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.


Hi @caduque,

From the drop-down list values, we can learned that the dates are consistent and have a predictable pattern.

  1. Each month has two dates. 15th of the month and last day of month
  2. 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



I think the values from the dropdown will change should we reach 2021.

Hi @supermanPunch,

How will I perform the DateTime Initialization?

@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))


Hi @caduque,

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.


What should I put in my Condition?

@caduque That depends on your Process actually :sweat_smile: , but I guess you can use Now.Day <=15

1 Like

I made a mistake on how to choose the cutoff.

It should be like this.

26 of the previous month to 10th of current month - bot should get the 15th

11th of the previous month to 25th of current month - bot should get the 30th.

@caduque Shouldn’t it be 11th of the Current Month to 25th of the current Month ? :sweat_smile:

If it’s 11th of the Previous Month to 25th of the Current Month, the First Condition Date Range falls under this category as well :sweat_smile:

You are correct :sweat_smile: it should be 11th of the current month to 25th of the current month

Badly need your help on this :sweat_smile:

I’m having trouble getting the Condition here. Is it still the same Now.Day <=15? I need to put in some range right?

@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.

Hi @supermanPunch,

Regarding your note, maybe you misunderstood on how we get the cutoff.

15th cutoff - 26th of the previous month up to 10th of the current month
30th cutoff - 11th of the current month up to 25th of the next month

I think it now covers all the days in a month. I need to assume that a month would always have 31st.
Sorry for the confusion

@caduque Then there’s a Change in the 30th Cut off Date Initialisation :sweat_smile:

But I can still use the code you’ve provided above?

@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 :sweat_smile: , Just go ahead and Implement the Steps that I have Provided and check if it works.

Hi @supermanPunch,

I understand what you are telling me :smiley:

When running the code you’ve provided, I am running to this error.

Please note that I have converted the variables DateFor26 and DateFor10 to .ToString so I can format it to match the values in the cutoff drop down.