How to calculate the date N business days later

Hello.
I’m a UiPath StudioX Enterprise Licence 2024.10.14 LTS user.

I know Excel’s WORKDAY function calculates a date N business days later, excluding weekends and public holidays. Could you please let me know how to achieve the same result using VB.NET syntax or a UiPath activity? There’s no need to account for special holidays such as the year-end and New Year holidays or the company anniversary.

@gorby

You can try this approach.

  1. Prepare holiday date list for the year as the default vb code won’t have it. You can prepare an Excel or CSV file.
  2. Read it using read range into a datatable.
  3. Use Assign activity or use Set Variable Value in StudioX to convert datatable Date column dates into a list. This is to make the calculations easy.
lstHolidays = dtHolidays.AsEnumerable().Select(Function(r) CDate(r("Date")).Date).ToList()
  1. Now use another Set Variable Value activity and calculate n th day in a DateTime variable.
    startDate - Datetime variable
    nDays - Int32 variable
nthDay = Enumerable.Range(1, 3650) _
  .Select(Function(i) startDate.Date.AddDays(i)) _
  .Where(Function(d) d.DayOfWeek <> DayOfWeek.Saturday AndAlso d.DayOfWeek <> DayOfWeek.Sunday AndAlso Not lstHolidays.Contains(d)) _
  .ElementAt(nDays - 1)

Sample code -

Holiday Excel:

Output:

Hi @ashokkarale

Thank you for your detailed answer.

However, I realized that using Excel’s WORKDAY function from UiPath is much simpler.

Thank you for your time!

Hi,
You can use Non Working Day on orchestrator: Tenant->Setting->Non-Working Days

And use the trigger settings → Non-working days restrictions

Hi @Hulya_CIVAK2 ,

I don’t use Orchestrator or Tenants at all!