Mchande
(Minesh)
April 8, 2023, 7:40pm
1
Hi All, I am trying to execute below to get minimum value from a data table and getting an error. Might be something simple but would love to get your input on how to solve it.
Assign Activity:
ExtractDataTableDetails.AsEnumerable().Min(Function (drRows) DateTime.Parse(drRows.Item(2).ToString)).ToString
Source: Assign
Message: The string ‘09/27/2022 08:02:02.797 A.M.’ was not recognized as a valid DateTime. There is an unknown word starting at index ‘24’.
Anil_G
(Anil Gorthi)
April 8, 2023, 8:01pm
2
@Mchande
Please try this
ExtractDataTableDetails.AsEnumerable().Min(Function (drRows) DateTime.ParseExact(drRows.Item(2).ToString.Replace("A.M.","AM").Replace("P.M.","PM").Trim,"MM/dd/yyyy hh:mm:ss.fff tt",System.Globalization.CultureInfo.InvariantCulture)).ToString
Cheers
Mchande
(Minesh)
April 8, 2023, 10:14pm
3
Hi @Anil_G - Thank you for replying. Now getting an error.
Source: Assign
Message: String ‘’ was not recognized as a valid DateTime.
Anil_G
(Anil Gorthi)
April 9, 2023, 6:20am
4
@Mchande
You have empty string in the column I guess use as below…
ExtractDataTableDetails.AsEnumerable().Min(Function (drRows) If(String.IsNullOrEmpty(drRows.Item(2).ToString.Trim),Now,DateTime.ParseExact(drRows.Item(2).ToString.Replace("A.M.","AM").Replace("P.M.","PM").Trim,"MM/dd/yyyy hh:mm:ss.fff tt",System.Globalization.CultureInfo.InvariantCulture))).ToString
Cheers
1 Like
Mchande
(Minesh)
April 10, 2023, 2:45am
5
Thank you @Anil_G . That helped!
1 Like
system
(system)
Closed
April 13, 2023, 2:45am
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.