Calendar/holidays

Hi All,
I am working on a scenRio where bot needs to pick up an excel workbook which was created 5 business days ago (filename will have date in it) and its should skip holidays also. Can someone helo me achieve this?

Thanks :blush:

1 Like

Hey @kaurM

When you say holidays is it weekends or the public holidays as well ?

Thanks
#nK

1 Like

Hi,

Both weekends and public holidays in canada.

1 Like

Hey @kaurM

I hope you have that list hopefully in an excel or something right ?

Thanks
#nK

1 Like

Hi @kaurM ,

As mentioned by @Nithinkrishna we have to maintain the public holidays in excel or some where so that we can make file name which contains date which we can calculate five business days ago except weekends and holidays.

In one of our usecase we have sane requirement for that we are using one database table which is having entire calendar year which tells each day whether it is working day or holiday based on that we will decide what is the date for five business days ago date.

Could you share us your logic on how to decide on the canda holidays. Based on that we would provide you suggestion. Thanks

1 Like

Hi

Hope the below steps would help you resolve this

  1. Use this website to get the holidays of Canada or any country you want and do a data scrapping and save it as a datatable named dt_holidays

  2. Now use a Assign activity like this

arr_files = Directory.GetFiles(“your folder path”).[Select](Function(f) New FileInfo(f)).Where(Function(f) f.LastWriteTime < CDate(DateTime.Now.AddDays(-5).ToString(“MM/dd/yyyy”))).ToArray()

Where arr_files is a array of string type

  1. Use another assign activity and get the dates of holiday from dt_holiday as a array of string

arr_holdiays = dt1.AsEnumerable.Select(Function( r) Convert.ToDateTime(r(“date ColumnName”).ToString.Trim)).ToArray

Note : instead of Convert.ToDatetime use Datetime.ParseExact function to convert as per the format we get from FileInfo
For Datetime format conversion refer this post

  1. Now use a FOR EACH activity and pass the above array variable arr_files as input and change the type argument as string

  2. Inside the loop use a IF condition like this

arr_holdiays.Contains(New FileInfo(item.ToString).LastWriteTime.ToString.SubString(0,10)) AND NOT( New FileInfo(item.ToString).LastWriteTime.ToString(“dddd”).ToUpper.Equals(“SATURDAY”) OR New FileInfo(item.ToString).LastWriteTime.ToString(“dddd”).ToUpper.Equals(“SUNDAY”) )

If true it goes to THEN part where you can get the files created five business days before and not on weekends as well

Cheers @kaurM

1 Like

Thanks very much :slight_smile:

1 Like

Happy automation @kaurM

1 Like

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