Select a pay period start and end date dynamically

Hi All,

I am dealing with pay periods in this situation. The bot needs to be able to select the beginning and ending of the existing pay period.

Pay periods start on saturday and end on a friday after 14 days.

I want the bot to select the highlighted period Dec 21 2019- Jan 3 Dec 2020 if it is running on any day between these two dates. Today’s date is 12/30/2019

Another example, Today is 1/2/2020 which means bot needs to select for start date 12/21/2019 and ** end date as 01/03/2020**.

Thank you for all the advice you all provide.

Capture

Hi @arsh

I don’t really get your point.
But my advice is you can try using UI Explorer to select the date you want from beginning to the end of the period through the attribute, hope it can help you somehow.

Another point is, did you already make sure the rule of your paying period?
Follow your 2 example, I couldn’t get the exactly rule

  1. Such as the date is 12/30/2019, so the beginning period start from the last Saturday(12/28/2019) or the Saturday from 2 weeks ago(12/21/2019)?
  2. If the date is 1/2/2020, why the beginning date still 12/21/2019?

Hope it can help you
If you have any problem, feel free to let me know

Cheers

@arsh
You have to establish a starting point. For example, if we pick any random date there’s no concrete way to tell if it’s in the first or second half of the pay period without tracing all the way back to your original dates of December 21, 2019 and January 3, 2020.

What you can do is save the original dates in a text file:
startDate,12/21/2019
endDate,1/3/2020

Read these in at the start of the bot’s execution and use them in your process. Then, at the end of the bot’s work (assuming it runs once per day), have it check to see if Today=endDate. If yes, add 14 days to each date and overwrite the file.

If you set it up this way it will use December 21 - January 3 up through January 3. It will then write January 4 - January 17 to the file so that next time it runs, on the 4th, it has the correct pay period.

@DanielMitchell The solution makes sense theoretically. Thanks for the idea.

I would appreciate if you could also mention how could(Like what specific UI tools) I make the bot select the specific dates based on the UI elements in the above attached screenshot?

@arsh
That will depend on the application you’re using and how well it can be automated. It looks like the month and year fields are in list boxes so you could try to use a Select Item activity. Once you have your dates saved as System.DateTime objects you can do startDate.ToString(“MMM”) to get “Dec” and startDate.ToString(“yyyy”) to get “2019”. Just indicate the appropriate drop downs.

image
The four digit year is also accessible via startDate.Year.ToString.

startDate.Day.ToString will give you the day, 21 in this case. I would try to inspect the calendar with UiExplorer. Hopefully the selector for each day will have a clearly defined label for the date where you can sub in your variable.