Doing Date Subtraction in Excel

I have a column(“Date”) in Excel with some Dates

I read this Excel as Data Table by Uipath
I created an Assign with:
DayNow =
DateTime.Now.AddDays(+0).ToString(“MM/dd/yyyy 00:00:00”)

And I made the following logic.

if CurrentRow(“Date”).ToString <= DayNow

So, if the Excel Date is Less than or Equal to today, it will return some specific value in another column.
Example: If the date is less than today = CRITICAL
else : WARNING

However, when I run the IF, the logic understands today and does the right procedure, but in the case of changing the year like: 2021, 2023 and others, the logic does not work

My doubt is, do I have to take the Excel column(“Date”) and transform a datetime to be able to make this comparison between dates and years?


Try like this




Let’s assume first digit is the month and the values are within the data table similar to excel

otherwise we use ParseExact to get more control (e.g. first digit is day)

And for checking what is inside the data table after read range / adopting the parsing format we can do:
:ambulance: :sos: [FirstAid] Datatable: Debug & Analysis invalid DateTime Strings / String to DateTime Parsing Issues - News / Tutorials - UiPath Community Forum

Error ERR Compiler error(s) encountered processing expression “CDate(CurrentRow(“Data de admissão sugerida”).ToString(“dd-MM-aaaa”)<Now.ToString(“dd-MM-aaaa”)”.
‘)’ expected.

Updated the above expression

Try it and let me know


Hi @Hendrix_Santos,

Make sure that the two values you are comparing are in date format.



Error ERRO Compiler error(s) encountered processing expression “CDate(CDate(CurrentRow(“Data de admissão sugerida”)).ToString(“MM/dd/yyyy”))<CDate(DiaHoje.ToString(“MM/dd/yyyy”))”.
Option Strict On disallows implicit conversions from ‘String’ to ‘System.IFormatProvider’.

I guess Currentrow may not be coming in a format to convert to date. Can you try the code above again? I added toString at the end of CurrentRow.

I made some adjustments and apparently it works, I will check more calmly and make sure of this logic. Thank you very much.

1 Like

I believe it’s the last mistake

If: Conversion from string “” to type ‘Date’ is not valid.

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