Saving holidays date for a year in excel and use that date to click previous day of holiday in calendar to run report in UiPath

Hi All,
I have setup an automation that needs to run on daily basis. I click on previous day date in calendar to get previous day report.
For example on Monday I run report for friday by using date(-3) and for tuesday day (-1) in if condition. But, I need a solution on what to do if there are like 8 holidays in calendar year and… for that day I would need a different date.
Can I input all holidays date in excel and use that date to check the holiday and put date to -1 or something like that? If so, how do I do this?
Thank you

1 Like

Hi @RamboRocky Well come to fourm,

For this you should ignore the Saturday, Sunday means you have to calculate the business working days.
The below link helps you to get the business days please refer the link

1 Like

To get the previous weekday

DateTime prevDay = date.AddDays(-1)

if(prevDay.DayOfWeek = DayOfWeek.Saturday)
prevDay = prevDay.AddDays(-1)


if(prevDay.DayOfWeek = DayOfWeek.Sunday)
prevDay = prevDay.AddDays(-2)

And for this

you can use the excel
Concept and that is a good one to proceed

Or

There are some approaches to achieve it. For example, if we can have holiday calendar in advance, we can use it.

or the following custom activity may help you.

UiPath Marketplace

Business Days Calculator - RPA Component | UiPath Marketplace

Calculates the amount of business days in a given range, depending on the locale. Can also output the actual business days.

Cheers @RamboRocky

1 Like

You can use this solution,

Chek the today Is Monday or not if it is monday then do -3 if not do -1

The code is below

DateTime.now.DayOfWeek

image

1 Like

Thanks for you reply @Palaniyappan .
I have got holiday calendar in advance. How do I go throught that approach. I have 8 holidays in a calendar year. So, just for that 8 days I would need to choose date for previous days to run a report. For example: if run report on tuesday. and monday is holiday I would have to choose Friday(-4) date.

Thank you for you reply @copy_writes
How would I make use of this flowchart. If there are holidays in different date of a year?

Once after I get this save it in a variable

Then read the excel file where u have saved the holiday list in sane date format as u get from above datetime expression

Now use read range and get the datatable as dt and iterate through for each row activity

Inside the loop use a if condition and check whether the any of the row value matches with the Datetime value obtained with above expressions

If yes u can skip it
If not u can use it

@RamboRocky

1 Like

Thank you I will give it a try and get back to you in a bit.

1 Like

Simple if you have a holiday date Excel file please read and check Today.ToShortDateString matches any holiday date.

if it matches do -1 and check once after you Minus that day is Sunday or Saturday.

1 Like

Hi mate!
Can you explain this please?
“Now use read range and get the datatable as dt and iterate through for each row activity”

After I read range… then do I have to build data table ? How do I do it? And After creating do I ‘for each’ the datatable dt? Can you provide me some example if possible please?

It’s that you have an excel file saved with holiday dates
That date has to be of same date format as you get from this expression

So once after excel file is ready then use READ RANGE activity and get the output as dt

Use FOR EACH ROW activity and pass dt as input which will iterate through each row

Inside the loop use a IF condition and compare it

@RamboRocky

Hi @RamboRocky

First you need to read the holiday list file loop through it and check with todays date is matching with the holiday list dates that you have in excel if the todays date matches with dates in excel then do -1 and here you also need to check today is monday or not if its monday then you need to do -3 if not -1 .

Regards,
Gayathri M K

1 Like

Do you have any examples for it please?

Hi mate! Could you probably do me an example of it like store some random date inexcel and read range and loop through to get me condition to match with yesterday date and run the condition please?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.