Comparing Dates

Good day,

I need some help with an automation.

I have an excel spreadsheet that has a date column, this column can contain any date value. eg. 1 Jan 2020, 13 March 2020, 25 December 2020 etc.

I prompt my users to input a date. Again this can be any date of the year.

The automation then needs to evaluate if the date entered is smaller than the date in the cell. When it finds a larger date it needs to return the row index from where I can calculate where to insert a new row (RowIndex - 1)

In my opinion Lookup Data Table is out because it is not an exact match.
I have tried Read Row but I dont seem to be using the IEnumerable object correctly
I assume I would have to use the IF logic but the math surrounding dates and where to do it has me stumped.

Appreciate the feedback.

Regards,

Here is one option,

You could enter the date at the end of the data table each time and sort the table by date. I’m not sure if this would be faster or slower than sorting through the table manually however. Try examining this link and see if sorting the data table for each entry, or even at the end of the workflow, could solve your issue.

Store both dates into Date objects and use DateDiff function to compare the dates.

Return Values. Because Date1 and Date2 are of the Date data type, they hold date and time values accurate to 100-nanosecond ticks on the system timer. However, DateDiff always returns the number of time intervals as a Long value.
If Date1 represents a later date and time than Date2 , DateDiff returns a negative number.

The output will be positive or negative based on whether the date is before or after the compared date.