Comparing the Date that read from excel

I got a date data read from excel in string format, and I want to compare today date or other date read from the datasheet.
How should I get the results?
I cannot directly minus the string and “cdate” doesnt work:
Read Cell: StringConverter cannot convert from System.DateTime.

1 Like

Hi @Andy_Chow

can you check these thread if it is applicable for your issue.

cheers :smiley:
Happy learning :smiley:

I heard I can also use datediff?
but it keeps saying Read Cell: StringConverter cannot convert from System.DateTime.

1 Like

Hi @Andy_Chow

Can you do me a favor can you screenshot your code .

thank you.

cheers :smiley:

Happy learning:D

datediff(dateinterval.Day, convert.ToDateTime(date1), convert.ToDateTime(date2)).ToString

or maybe the format of the date read from the excel is already in datetime format?

1 Like

Hi @Andy_Chow

Did you try to debug it,what activity that cause the error?

cheers :smiley:

Happy learning :smiley:

the error before is fixed by selecting preserve format
but no still cannot calculate the diff between date and today
datediff(dateinterval.day, convert.todatetime(date1), now.date)

This video will solve your problem @Andy_Chow : Learn How To Compare Dates In UiPath - YouTube

Mark it as a solution if it works.

Cheers,
Parth