How to convert a string type "MMM yyyy" to datetime

Hi,

I’m using DateTime.ParseExact(meseRif,“MMMM/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

to get a datetime variable from a string “January 2022”. I have also changed my CultureInfo to set it to Italian.

Any idea?

Thanks

You have your format as MMMM/yyyy but you don’t have a / in “January 2022”

Confirmed within the immediate panel it works:

As Paul has mentioned adopt the format specifier

Many thanks to everyone!

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