Problem with a DateTime Parse

I have a dates on spanish “17-dic-24” and I’m trying to change into “dd.MM.yyyy” format. I am testing with this expression "DateTime.ParseExact([variable], “dd-MMM-yy”, System.Globalization.CultureInfo.CreateSpecificCulture(“es-ES”)).ToString(“dd.MM.yyyy”) but I received this mistake “Assign: String ‘’ was not recognized as a valid DateTime.”.
I noticed when I tested one expression to give me the date in Spanish the system gave me like this “17-dic.-24” with a dot after the month, when I put the dot on my variable it works perfectly, but the variable comes from the input file.

Any idea to solve the problem ??

Hi,

How about the following expression?

DateTime.ParseExact(System.Text.RegularExpressions.Regex.Replace(yourString,"(?<=[A-Za-z])(?=\-)","."), "dd-MMM-yy", System.Globalization.CultureInfo.CreateSpecificCulture("es-ES")).ToString("dd.MM.yyyy")

Regards,

Hi tnks works perfectly

1 Like

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