How can I manipulate a date to be one working day before the date saved in the UiPath variable?
I saved data in a variable “data_saved”, for example, and this value of data_saved is not a fixed value, this value will vary according to the reading of a pdf file that will be executed.
My variable is a substring and I need a working day of the week and not holidays… I tried .add(-1) but there are cases where the day is a holiday. I need it to be one business day before the date saved in the variable.
I think I expressed myself wrong and I already apologize. I get the date from a pdf file, I need to handle it when inserting, currently it looks like this: Split((Split(pdf,“DATE DATE”)(1).ToString),“V”)(0).ToString
I need to transform this so that it is always on a working day, and I don’t know how to do it, your example would serve me in a datatime, but it doesn’t apply or at least I can’t apply it to my need
I think I expressed myself wrong and I already apologize. I get the date from a pdf file, I need to handle it when inserting, currently it looks like this: Split((Split(pdf,“DATE DATE”)(1).ToString),“V”)(0).ToString
I need to transform this so that it is always on a working day, and I don’t know how to do it, your example would serve me in a datatime, but it doesn’t apply or at least I can’t apply it to my need
Unfortunately I couldn’t do it, I’m still researching and testing.
I was wondering if it’s possible to create a variable that checks for holidays, another variable that checks if it’s Saturday and another variable to check if it’s Sunday.
I would do an if on these variables and subtract one day. Is this possible?
I have created a workflow, as I thought it was a bit tricky to understand, as we would be needing the closest working date before the extracted date. Check the below workflow : GetPreviousWorkingDay.zip (3.0 KB)
A few important/short summary of workflow is provided below. As I think the workflow is a bit too long, others could also have a look on these methods and maybe would be able to provide a better/ shorter approach.
To Check for holidays, you would require to have the list of holiday dates according to your/Client calendar and then use it to check if the date extracted/received is a holiday date. Creating a list as shown below :
To Check for weekends also you would require to have the list of weekend dates. So that you will be able to exclude the dates at the end when calculating the Working dates alone. To Calculate the weekend dates, we can use the below Expression which will calculate the weekend dates from the 1st day of the year upto the current day.
Here, DifferenceInDays is calulated as from 1st of year to Current Date, WeekendDatesUptoCurrentDate is an Array of DateTime variable.
Next, the weekend dates and the holiday dates calculated are concatenated into one list, TotalNonWorkingdates and is used to calculate the TotalWorkingDates.
We can now find the closest working date before the extracted date using the below expression :
Here, the extractedDate is your date extracted from PDF. We would also need to know the format of the date, as it was assumed it will be in the format MM/dd/yyyy.
Visuals of the working :
Let us know if you were able to understand the workflow and able to get the required output for the extracted date received.