Convert month name to number from extract

I extract a date from a PDF and it comes out as March 23, 2022. I need to convert the March to 03. Every time this process runs, the date will be different so it needs to be dynamic. Not sure what the way to do this is.

hey

try with that

Datetime.ParseExact(input_month ,“MMMM”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM”)

regards!

I tried that and got “Assign: String was not recognized as a valid DateTime.”

@atarantino

Try below expression to convert only month name to number.

Datetime.ParseExact(inputDate ,“MMMM dd, yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM”)

If you want to replace month name to number along with the date then try below expression.

Datetime.ParseExact(inputDate ,“MMMM dd, yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM dd, yyyy”)

what was your input?

image

it should work

Hi @atarantino ,

If the date comes in the format of MMMM dd, yyyy, then this ought to work →

image

DateTime.ParseExact(str_variable,"MMMM dd, yyyy",Nothing).ToString("MM")

However, if there are multiple possible formats, then it can be handled to an extent.

Kind Regards,
Ashwin A.K

i needed to add the dd, yyyy after the MMMM. Then it worked. Thank you.

1 Like

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