hello, i must get the greatest date, from this column, can someone help me please
HI @GDMM
Checkout this expression
dt.AsEnumerable().Max(Function(s) DateTime.ParseExact(s(Fetcha de Factura).ToString,{"dd/MM/yyyy","d/M/yyyy","MM/dd/yyyy","MM/dd/yyyy hh:mm:ss"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None)).ToString("dd.MM.yyyy")
Regards
Sudharsan
is assigned to a variable of what type?
@GDMM Can you check any value is empty or any other formats apart from this in your datatable
{“dd/MM/yyyy”,“d/M/yyyy”,“MM/dd/yyyy”,“MM/dd/yyyy hh:mm:ss”}
Hi @GDMM ,
When concentrating on the Latest Date Value, we can do it by configuring a pre-Check to avoid empty values in the Expression that @Sudharsan_Ka provided, Like below :
DtLote12Hoj2.AsEnumerable().Where(Function(x)Not(String.IsNullOrWhiteSpace(x(0).ToString))).Max(Function(s) DateTime.ParseExact(s(0).ToString,{"dd/MM/yyyy","d/M/yyyy","MM/dd/yyyy","MM/dd/yyyy hh:mm:ss","MM/dd/yyyy HH:mm:ss"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None)).ToString("dd.MM.yyyy")
Let us know if this is not what you require or not working. Let us know what error you get when it doesn’t work.
Thank you very much, this is the solution
1 Like
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.