Older date

hello, i must get the greatest date, from this column, can someone help me please

Captura de pantalla 2023-02-13 022740

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?

String type @GDMM

I get this error

@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”}

Can you print the datatable in message box using output datatable activity
and share here? @GDMM

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.

Can you scroll and check if there is different format dates available? @GDMM

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.