How to sort a Datatable by date?

Can u show me ur code line where you have used culture info

1 Like

check if you have System.Globalization in ur name space

1 Like

@Sriharisai_Vasi

@Aibek_Abubakirov
here is to import the namespace like this
grafik

1 Like

I have only these @ppr
image

then add System.Globalization

1 Like

image

Same error as above from the past, where the first fox was done with a trim
As the message tells. String is not in a form of a valid DateTime so the parsing fails

Without knowing what is the latest implementation and its details we only can give a general hint: Check the values on its format and ensure that no unneeded spaces/other characters are sent into the process

1 Like

@Aibek_Abubakirov

dd/MM/yyyy is shown in screenshot dd.MM.yyyy is used in the parse format.

Here you have only set the Parser format to the right format and then it will work. Implementation was done by the given requirements. If requirements have been changed then sure you should change the implementation

1 Like

@ppr where can I still set the dd.MM.yyyy format?

the format is already installed, no?

From d In dtData
Let dt = DateTime.ParseExact(d(“Сроки действия до”).toString.Trim,“dd.MM.yyyy”, CultureInfo.InvariantCulture)
Where dt >= Now And dt <= Now.AddDays(16)
Order By dt
Select d).toList

the bold text shows the format that is expected for the parsing and it has to match the format of the date data

1 Like

thank you very much for your help, you helped me a lot, good luck! :+1:

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