Soudios
(Sou)
1
Date time is dd/mm/yyyy 00:00:00 and other time is dd/mm/yyyy and other time is dd-mm-yyyy 00:00:00 and other time is dd-mm-yyyy
Can i do this ? :
DateTime.ParseExact(Date_Piece.Trim(),{“dd/MM/yyyy”, “dd/MM/yyyy HH:mm:ss”,“dd-MM-yyyy HH:mm:ss”, “dd-MM-yyyy”},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString(“dd-MM-yyyy”)
Hi @Soudios,
Almost your code is correct you have to create instance of the date format array with new keyword please try the below code
DateTime.ParseExact("23/07/2022",new string[] {"dd/MM/yyyy", "dd/MM/yyyy HH:mm:ss","dd-MM-yyyy HH:mm:ss","dd-MM-yyyy"}, System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.None).ToString("dd-MM-yyyy")
Hi @Soudios
Your code is working fine