Hi there,
I have a datatable extracted from a csv file.
The datatable has multiple columns and one of them is a date column which is a string type.
I could read range from csv file, but cannot extract oldest (min) and latest (max).
I tried this below image referencing from this post: Select(find) max date from datatable .
Dt.AsEnumerable().Max(Function (drRows) DateTime.Parse(drRows.Item(8).ToString)).ToString
However i got an error:
How do I get this correctly??
ppr
(Peter Preuss)
July 22, 2021, 9:22pm
2
Exception occurs if the date string is within a form that is not parseable by the DateTime.Parse method.
I that case a quick analysis on data from the datatable will help
set a break point on relevant location
debug the bot and get pause
open immediate panel
use following statement: dt.Rows(0)(8).toString
please share the output with us, so we can further help. Also check the CSV file that all dates are consistent in the format and not empty
Hi
Thank you for your reply.
I have never used immediate panel and am not sure if i did it right. but here’s the output.
I checked the csv file and the dates are consistent since it was downloaded file.
ppr
(Peter Preuss)
July 22, 2021, 9:50pm
4
Perfect you have done correctly
175 is not a date string. Kindly note column index is 0 based. Maybe the date is within another column. Can you check this please? Thanks
You are right.
I put a wrong column index.
I spent a lot time to solve this, and didnt even notice that.
Thank you so much for your time.
ppr
(Peter Preuss)
July 22, 2021, 10:07pm
6
Perfect. Issue is identified. This can happen to all of us.
Just do your final testing. Let us know your further open questions. Once it is working please mark the solving post as solution. So others can benefit from it.
Thanks
Peter
1 Like
system
(system)
Closed
July 25, 2021, 10:07pm
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.