Max Date not found in Data Table

Hi All,

I am trying to compare two dates in a Data Table. Its correctly picking the two dates.

image

But after comparing it throws exception Max date not found Below is the screenshot.

image
image


image

Hi @marina.dutta

It was not matching the condition the excel date and max_date are not equal that’s why it was going to else and throw the error.

Hope it helps!!

@marina.dutta
Hi,

Try to store the maximun date in a variable ant then loop the dates and give the scope to main sequence.

Thanks

@marina.dutta

As per the condition you are checking if the dates are exactly matching and as per log messages your dates are different

Let us know what you want to check is it equals only?

cheers

@Anil_G

Actually the I am looping the data table and checking if current row is max date . Incase the current row of the data table is max date it will click the max date. Do I need to include continue in my loop so that it goes to the next iteration and compare

Hi @marina.dutta

Your dates are not equal so it goes to else and throws an error

@marina.dutta

Please check the dates were not same so the if condition is not satisfied and it went to else block and thrown the error

Regards

Hi @marina.dutta

The output results are true. As the dates are not equal it is throwing exception

Hope it helps!!

@marina.dutta

Why not filter the datatable and get the required row directly?

after filter you can check filtereddt.count>0

cheers

Its not looping the second row . Do I need to use continue.

@marina.dutta

Remove the throw activity so that the iteration will be continued.

regards

@marina.dutta

Delete the throw activity.

@Anil_G

@marina.dutta
Remove the throw activity

@marina.dutta

Remove your throw activity …

you can include throw after for loop checking if click has happened or not

or ideally can follow using innertext as date and click would happen directly if present

cheers

Then loop the datatable in for each row in datatable and compare the condition in If condition.
In then condition give the click activity and in else don’t give any activity.

If you give throw it will stop at that throw and throws the error.

Happy Automation!!

@marina.dutta

You can simply get the max date by using this expression:
str_output = [YourDTVariable].AsEnumerable().Max(Function (drRows) DateTime.Parse(drRows.Item([YourColumnIndex/Name]).ToString)).ToString

Then pass the str_output variable in click activity selector to directly click the max date.

Hope it helps.

@pravallikapaluri @supriya117 @mkankatala @Anil_G @vrdabberu

Thanks everyone.

2 Likes

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