Change date format in Spanish

Hi everyone,

I have a date stored in a variable at this format dd/MM/yyyy andI want to change at this one “MMMM” the problem is I need in Spanish, I’m using the next expression:
DateTime.ParseExact(variable,“dd/MM/yyyy”, CultureInfo.CreateSpecificCulture(“es-ES”)).ToString(“MMMM”)

But it does not work, it converts in English.

Any idea??

Hi @Diego_Marquez

Check the below expression,

DateTime.ParseExact(variable, "dd/MM/yyyy", CultureInfo.CreateSpecificCulture("es-ES")).ToString("MMMM", CultureInfo.CreateSpecificCulture("es-ES"))

Check the below image for better understanding,

Hope it helps!!

Hi @Diego_Marquez ,

Kindly try below Expression

DateTime.ParseExact(DateTime.Now.ToString("dd/MM/yyyy"), "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("dd 'de' MMMM 'de' yyyy", New CultureInfo("es-ES"))

You can replace DateTime.Now.ToString(“dd/MM/yyyy”) with your variable|

Below is the output for your reference

Hope it helps you out!

Tnks a lot it works perfectly

1 Like

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