iNPUT STRING IS NOT AN VALID STRING

Hey guys,

Am trying to convert a string to date . The input is “26/4/2023” i used parseexact even though am getting an error .Kindly help

Hi,

How about the following expression?

DateTime.ParseExact("26/4/2023","d/M/yyyy",System.Globalization.CultureInfo.InvariantCulture)

Regards,

Thank you so much . That helped

Hi @bharathi_ganesan

Actually we follow American style Gregorian date format i.e MM/dd/yyyy. You need to give the input string in the format of MM/dd/yyyy as string and convert to date format.

If your given input format should be same as you have mentioned follow the below syntax

DateTime.ParseExact(input,"dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture)

Hope it helps!
Regards,

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