How to validate today is working day or not?

Hello, all

I’d like to validate that today is working day or not.
After that I’ll use the output result with IF condition.
If Tuesday is working day , it should calculate last Tues to Mon. Otherwise, it has to set last Tues to Sun.
Could you please help for validating working day value?
Region: KR and Robot will be running every Tues.

If you’re looking normal calendar… then I guess so Saturday and Sunday are the non working days.

Then to find the current day you can use this simple method Now.ToString("dddd") - It returns the current day, then you can evaluate if the output is not Sat & Sunday then you’re good to go!

Inaddition to what @ManiPrajwal_K said

you can try this in if condition

Now.DayOfWeek.ToString<>“Sunday” Or Now.DayOfWeek.ToString<> "Saturday"

Regards,
Nived N
Happy Automation

1 Like

I’ve attached a small sequence to find out if Today is holiday.
Details of the Sequence:
Holiday is an array of Strings which holds the week days that are holidays eg:Sunday,Saturday
CheckDay is a Str var to hold today’s week of the day

hope this is helpful

you can manipulate the holidays based on the strings in the array Holiday

Main.xaml (5.4 KB)

@NIVED_NAMBIAR Thank you for your reply!
By the way, it has to identify KR public holiday… which is non-business day.
Can it be possible?
It doesn’t have to verify Sun or Sat. Sorry for lack of information

hi @Dorothy_lee
what u mean by KR public holiday ?

@NIVED_NAMBIAR kind of this date.
ttps://www.officeholidays.com/countries/south-korea/2021

to identify holidays other than wkends we need to maintain holiday list (in excel/notepad) and refer it back to check if that list has today’s date.

Hi @Dorothy_lee

Just got with the @AdityaVN suggestion, scrape the holidays list from the website and using that manipulate whether the day is holiday or not

Regards,
Nived N
Happy Automation

@AdityaVN @NIVED_NAMBIAR Thank you for providing alternative ways. I’ll try that way and update the result here

2 Likes

There is of course a lot of cultural bias here, defining what a working day is.
Mostly it is mon - fri, with exception of several national holidays.

So you need to do 2 checks:

  • is the day monday-friday (or not saturday-sunday, whichever is easiest). Achivable by the examples above on getting the workday as part of the date: MyDate.DayOfWeek retuns the specific weekday having MyDate as a date or datetime datatype.
  • is the specific date a non-working holiday. You might be able to scrape this from some website, but that leaves your process with an external dependency on that site. I’d avoid that myself. I would probably set some asset or a small text- or excelfile with a list of holidays to validate against.

So is my date a basic workday and not in my exceptionlist → then it is a workingday.

@NIVED_NAMBIAR @AdityaVN Hello, I found that local custom activity which is getting data from Korea National Official data website API.
But it’s output data type is Dictionary so it cause below error. Is there any way that I can resolve this issue?
image


Hi @Dorothy_lee

Can you take a look to this document
Calendars Requests (uipath.com)

You can define your own Calendar on the UiPath Orchestrator, get it from your robot and compare if the date you are evaluating is one of the ExcludedDates by using the Orchestrator API.

Pros: You can set the dates your company/organization defines as non working days and update them directly on the Orchestrator.

Cons: You have to set manually all the non working days. The good part it is you can import a calendar as csv to create the UiPath calendar.

Bests,
Andres

Hi

Dictionary can be manipulated to your requirement. But my suggestion is to avoid API calls unless it is absolutely necessary as this will add time to the process.

Instead you can have all the holidays in excel like below (Indian Holiday list), read it as a DataTable,
iterate through each row
add only the dates to a collection variable - you can use Add to Collection activity
check IF collection_var.Contatins(checkDay)

I’ve attached a sequence which check for working or holiday based on the dates in the excel present along with it. It can be invoked in your workflow by converting ‘CheckDay’ as input argument and ‘Result’ as output argument.

Let me know if this is helpful

WorkingORnot.zip (11.2 KB)

Thank you so much for suggesting alternative ways but could you please attach ,xaml file again? I’m unable to open it.

Hello, I’ve just created based on your comment since I couldn’t open the file.
By the way, It seems like almost correct but when I test it the result is wrong. Could you please review where is wrong…?
This test file contains today date so, it should show " Holiday" but shows “No Holiday” comment




I’m wonder that which value should be input in item field?

Hi
yes you identified the reason correctly, Add to Collection will take two input arguments - one is the collections variable (List_Date) and other is holiday date.

Create a datetime var (tempdate)
assign tempdate = Convert.ToDateTime(row(0).ToString)
in Add to Collection properties assign tempdate to Item

attached the xaml.

image
image

WorkingORnot.xaml (12.9 KB)

Thank you for your kind reply. Is there any way that I can see your process?

And also, I found below error message when I added new Assign which is Tempdate


Holidays file is same file that you shared in advance
format is d-MMM(ex. 01-Jan)

Thank you so much !! I finally solve the issue
I added item(0)

Glad to know it is solved

Cheers