The datetime.parseexact is not taking string() in format argument

Hi folks,

The recent code: DateTime.ParseExact(“my_date_str”, {“MMMM yy”, “MMMM yyyy”}, System.Globalization.CultureInfo.InvariantCulture).ToString(“MMM yyyy”)
was working.

Now after a month, it’s throwing an error stating we can’t use string() in format but string.

I have tried downgrading/upgrading system package still the issue persists.

Hi @Aakash_Singh_Rawat

Try the below syntax:

DateTime.ParseExact("my_date_str", {"MMMM yy", "MMMM yyyy"}, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None).ToString("MMM yyyy")

Hope it helps!!

1 Like


1 Like

Thank you @Parvathy,

It works, minor issue it was :smiley: :smiley:

1 Like

You’re welcome @Aakash_Singh_Rawat

Happy Automation!!

1 Like

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