How to add 5 business days to the date


#1

I would like to add 5 business days to a certain date.

which means i have to be aware of sat and sun

is this possible in uipath?


#2

Hi @Seonyong, I guess you check all the days of the month, so check in your decision if the current day is different of sat or sun.

date.now.day.tostring <> “Saturday” or “Sunday”

Regards :mage:


#3

Isn’t 5 business days always exactly a week? You could just add 7 days. Except for holidays I guess, but I don’t think it’s easily possible to have them in consideration…


#4

of course i should consider holidays so i believe i should make excel file of working days and utilize that file to calculate


#5

Hi,

The best solution for this would be a especific workflow.

In my case i build a “GetNextNWorkDay” build a workflow:

2 in atributtes: 1. DateOrigin 2. Number of days
1 out atribute: 1. DateOut

Workflow should be like:
dateOut=dateorigin
for each Enumerable.Range(0,Math.Abs(Number of days))
do
dateOut = dateOut.AddDays(NumberOfDays/Math.Abs(Number of days)) Note: this will work forwards and backwards if only want one direction just place +1 or -1.
while ({DayOfWeek.Saturday,DayOfWeek.Sunday}.tolist.contains(dateOut.Contains(dateOut)
end for each

this will work :slight_smile:

In order to explain it a little bit further:

  1. It will get next work day N times but it will count only workdays between N.

This oslution works with holydays if you add a list of Date as input and add something like (listHolydays.Contains(DateOut.Date) in the while condition


#6

wow this helps a lot thank you!!


#7

Hi Ignacio - Could you please share sample XAML file for this. This would be great support for us. Thanks!


#8

Hi Can you please share the XAML file for business day calculation.


#9