Check if today is twentieth working day

Hi, the robot every day needs to check if today is the twentieth (20th) working day in the month. Non working days are Saturday and Sunday.

Hi @markosc ,

Try below workflow, let me know if you have any query
CheckSunday.xaml (5.2 KB)


If we don’t need to consider public holiday etc, the following step helps you.

First, set the following variable using Assign activity.

arrMaster = {27,26,28,28,28,28,28}

Then, condition will be

Now.Day = arrMaster(CInt(New DateTime(Now.Year,Now.Month,1).DayOfWeek))


Hey is it worked ?

we would understand the requirement as 28th July is the day of interest as it has a workday count of 20.

So following LINQ can help:

(From x In Enumerable.Range(0, now.Day).Reverse
Let dw = now.AddDays(-x).DayOfWeek
Where dw >= 1 And dw <= 5).Count = 20

Running it in a test serie we get:

How can I also write line the date of the twentieth working day because I also have to compare it to the dates in excel and isWD20 is type boolean

the log messages was the output of a test serie, just for validation the implementation.
Not sure If we got your question. May we ask you to reformulate it or the requirement

Yes, is boolean

I have an excel file with dates of holidays, if today is twentieth working day and if the list of holidays contains it, then the twentieth working day is the next day (also needs to exclude weekend)

in that case we can do

read in the holiday dates into a list of dateTimes - listHolidays
create a list of dates from first of month till today excluding the weekend days - listWorkdays
substract the Holidays from Workdays by Set Operation
listWorkdays.Except(listHolidays).toList - ListWorkdaysFiltered
Check the count of ListWorkdaysFiltered - ListWorkdaysFiltered.Count = 20

listWorkdays can be done by following:

(From x In Enumerable.Range(0, now.Day).Reverse
Let d = now.AddDays(-x).Date
Let dw = d.DayOfWeek
Where dw >= 1 And dw <= 5
Select d).ToList

Kindly note: in some countries / Cultures there are 2 holidays on series or also within a range more holidays can occur. So mandatory next day is to take if Holiday occurs has the rist to be invalid

Corrected, will return a list(Of DateTime)

How do I read excel into list of datetime?
for example I have read it but as list of string

(From row In prazniciDt.AsEnumerable() Select((row(“Datum”).ToString))).ToList

Its depending on how the excel values are read in into the datatable
Give a try on
(From d in dtData.AsEnumerable
Let dp = DateTime.ParseExact(d(“Datum”).toString.Trim, “MM/dd/yyyy HH:mm:ss”, CultureInfo.InvariantCulture)
Select dd = dp.Date).toList

Ensure following:

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