Parsing a hard DateTime

Hi, I’m not new at parsing datetimes, but this one is giving me a rather hard time.

I need to parse the following structure, from String to DateTime:

Sep 4th 2007

After searching on the internet, I found that this format can help… But it didn’t work.

DateTime.ParseExact(strDate.Trim, "MMM dd/DD YYYY", System.Globalization.CultureInfo.InvariantCulture)

If someone knows how to parse a 3 letters month, Ex: “Apr”
And a day of size 1 or 2, with suffix, Ex: “3rd” or “31st”.

Any help will be appreciated it.


Can you try the following expression?

DateTime.ParseExact(System.Text.RegularExpressions.Regex.Replace("Sep 4th 2007","(?<=\d+)[A-Za-z]+",""), "MMM d yyyy", System.Globalization.CultureInfo.InvariantCulture)


1 Like

Thank you, that’s exactly what I needed.

1 Like

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