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
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
Hi,
Both weekends and public holidays in canada.
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
Hi
Hope the below steps would help you resolve this
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
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
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
Now use a FOR EACH activity and pass the above array variable arr_files as input and change the type argument as string
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
Thanks very much
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.