I’m encountering an issue while trying to convert dates in different formats into a specific format (dd/MM/yyyy). I have dates in the following formats:
22/Oct/2024
06/22/2023
18.11.2023
When I attempt to convert them to the format 22/06/2024, I’m getting this error:Assign: String ‘’ was not recognized as a valid DateTime.
i am using this method : Convert.ToDateTime(“26/6/2024”).ToString(“dd/MMM/yyyy”) still it is throwing error
Hai
Thanks Your response
but i tried this method but it is not working
DateTime.ParseExact(“06/22/2023”, “MM/dd/yyyy”, CultureInfo.InvariantCulture)
i don’t have specific format i am getting diffarent formats but i want to convert "dd/mm/yyyy " this format only
Go on adding the different types of date formats. Hope this helps. Please check and update
Note: In the above expression D_format is nothing but input date
As 5th July 2024 - 05-07-2024 is ambigious to 7th May 2024 - 05-07-2024
above approach cannot reliable handle all formats and prefers the first format match
We should keep this in mind. However in such a case, when ambiguous dates are expected, then we should detect and handle very carefully