Hi Team
I have to convert the different input date formats into a specific output date format.
input:- ‘23-10-2023’
output- ‘23 Oct 2023’
But I have made some errors.
How can I solve this error:-
Assign: String ‘23-10-2023’ was not recognized as a valid DateTime.
System.FormatException: String ‘23-10-2023’ was not recognized as a valid DateTime.
Thanks
Minal P
Hi
Say you have a date string which can be of different formats for each time it is being used like
“dd/MM/yyyy”, “MM/dd/yyyy”, “dd/yy”
Then have all these possible formats in a array variable named arr_formats
Like this
arr_formats = {“dd/MM/yyyy”, “MM/dd/yyyy”, “dd/yy”}
Then to convert that string as Datetime
var_datetime = DateTime.ParseExact(Strinput.ToString, arr_formats, System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.None)
Cheers @minal.patil