Change the format of a date

Hello friends I need your help, you need to change the format of a date from 10-Dec-2020 to 10/12/2020 the variable type is string and in Spanish: D

DateTime.Parse(“10-Dec-2020”).ToString(“dd/MM/yyyy”)

Obviously, replace the hardcoded 10-Dec-2020 string with your variable.

1 Like

Muchas Gracias

chicos tengo un problema, al escribir la fecha 10-Dec-2020 me he dado cuenta el que dato viene en minuscula es decir 10-dec-2020 o tambien 10-ene-2020 y al llegar ese dato en minucula me arroja un error (Assign: The string was not recognized as a valid DateTime. There is an unknown word starting at index 3.) algo que pueda hacer?

Guys I have a problem, when writing the date 10-Dec-2020 I have realized that the data is in lowercase, that is, 10-Dec-2020 or also 10-Jan-2020 and when that data arrives in minute it throws an error Assign: The string was not recognized as a valid DateTime. There is an unknown word starting at index 3.) Anything I can do?

DateTime.Parse(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(yourStringVar)).ToString(“dd/MM/yyyy”)

1 Like

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