How to compare a String and DateTime Type in a For Each Row activity? (ERROR: Options Strict On disallows implicit conversion from 'Object' to 'String')

I am trying to compare two variables in a For Each Loop. One is a ‘String’, the other is a 'DataTime."

I’ve tried converting the string to the DateTime type using:

datetime.ParseExact(row.Item(“Date”),“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

But keep on getting the error “Options Strict On disallows implicit conversion from ‘Object’ to ‘String’”

What should I do to compare these two variables?

try converting the date time one to string and see if it works
also check this maybe it can help: https://youtu.be/SPS-LMt0660

Give a try to and use IT for compare with a datetime

datetime.ParseExact(row.Item(“Date”).toString,“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

Hi, welcome to the community!
if you are getting that error, most likely that datatable column named Date is already of DateTime type… You should not try to parse it as a date again…

Hi, thanks for your response!

When I try to assign the variable however to just “row.item(0)” I get the error:

"Cannot assign from type ‘System.Object’ to type ‘Sytem.DateTime’ in Assign activity ‘Assign.’

So my new question is. How do you convert an Object to a DateTime?

Thanks

Hello, thanks for your response. I am trying to compare two dates, so converting it to a string does not compare correctly.

Hello, thanks for your response. I have tried this, and I would still get the same error sadly.

@ahn661707
Use row.item(0). ToString

and then you can use Compare Date Activitiy. It is explained completely in the video I have shared.

@ahn661707
have a look below


Line 1: a date value from the row’s Date column
Line 2: the parsing result
Line 3: the parsing in a short form, when System.Globalization is imported as following:

grafik

in case of your implementation is not working as expected then go for debugging / setting Breakpoints and analyse the different variable values and statetements. Quick statement checks can be be done in the watch / immediate panel as well

I was able to fix the problem. Thanks so much! Should’ve watched the video in full first time around.

Great @ahn661707