How to convert a written month into its corresponding number

Hi friends,

I’d like to know if there’s a way that I could convert this date “11-dez-1989” to “11-12-1989” where “dez” is a abbreviation of Dezembro in Portuguese. In English is December.

I tried this:Assign- birthday = "11-dez-1989"

Then I use a second assign:
Capture2

And the expression in the second Assign activity is:

DateTime.ParseExact(birthday,"dd-MM-yyyy",System.Globalization.CultureInfo.CreateSpecificCulture("pt-BR")).ToString("dd-MM-yyyy")

However, I get the error: Assign: String '11-dez-1989' was not recognized as a valid DateTime

I extract the data from a csv file which is written in Portuguese, that’s why I have to use the Brazilian Date Time Format. This date I have to put in a web form that only accepts the dd-MM-yyyy pattern.

How could I solve this issue? I’ve tried pretty much everything that I know.

Hi

This is really good approach. Try to use ‘dd-MMM-yyyy’ pattern instead of 'dd-MM-yyyy’in ParseExact method.

Thank you @Konrad_Mierzwa

It worked like a charm!

The entire expression now is:

DateTime.ParseExact(birthday,"dd-MMM-yyyy",System.Globalization.CultureInfo.CreateSpecificCulture("pt-BR")).ToString("dd-MM-yyyy")

Thanks again!

1 Like

How this expression is working for you? @Rodrigo_de_Bem

For me it throws an error. Can you check out this

image

Regards
Gokul

Hi @Gokul001

It is working, here’s the output now
Capture

In my side it throws an error @Rodrigo_de_Bem

Regards
Gokul

It is strange. Could you check these expressions:
image

@Gokul001

That’s strange. The date format in my computer corresponds to the Brazilian pattern. Does it make a difference is this case?

If i try like this its working for me also @Konrad_Mierzwa

So the cultureinfo works correctly in your case. I have no idea why this previous expression throws an error for you. That’s really strange

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