Option Strict disallows late binding inside foreach loop

I am working an project that uses federal holidays to send emails differently. I store the holidays in excel file then read into datatable at runtime. After the holidays are read into datatable, I tried to loop via the holidays list to test for the day of month and the month is equal to current date’s day of month and current month in the if activity.
The logic goes as follow:
forEach item in holidays{//forEach activity ===>no issues at until here
if(item.Day.ToString.Equals(currentDate.Day.ToString) And item.Month.toString.Equals(currentDate.Month.ToString)){//if activity: Error occurs here: Option strict disallows late binding
isHoliday = True; //assign activity
isHoliday = False;

Why Am I getting this issue. Given that the holidays variable is a list of DayTime as well as currentDate

@dari_donkuro What is the type of Item and what is the type of currentDate ?

Your For Each loop has an option to set the datatype. Choose DateTime instead of object, and then if item.Day = currentDate.Day) will work.


Thank you very much @Anthony_Humphries. I didn’t know I set dataype. That worked out perfectly.

Hi @dari_donkuro,

Welcome to the Uipath community! Has your issue been resolved? :smiley:

Yes. @Anthony_Humphries suggestion worked nicely.