Help with the Error String was not recognized as a valid DateTime

Hi, dear Colleagues

I would like to know if someone has presented the following error.

I have the same sequence for handling the date, both receive the same input, however when I pass that sequence to a Reframework, I get the following error: Assign: String was not recognized as a valid DateTime.

I attach the initially prints of the functional sequence where I get MM/dd/yyy as a result

However, when I pass it to the RE, M/dd/yyyy appears and it finds the same formula

image

strFecha = Convert.ToDateTime( strFecha, New system.Globalization.CultureInfo(“es-MX”)).ToString

Hi @SADID_ALEXIS_ROMERO_MAHEC
var_datetime = Convert.ToDatetime(Strinput.ToString)

Make sure var_datetime variable should be datetime type.

Regards,
Kaviyarasu N

HI @SADID_ALEXIS_ROMERO_MAHEC

Checkout this Expression

DateTime.ParseEXact("DateString",{"MM/dd/yyyy hh:mm:ss","M/dd/yyyy hh:mm:ss tt"},System.Globalization.CultureInfo.CultureInfo.GetCultureInfo("es-MX")),System.Globalization.DateTimeStyles.None).ToString("YourFormat")

Regards
Sudharsan

Hi, Sudharsan

i get the following error

@SADID_ALEXIS_ROMERO_MAHEC

Try This

DateTime.ParseExact("DateString",{"MM/dd/yyyy hh:mm:ss","M/dd/yyyy hh:mm:ss tt"},System.Globalization.CultureInfo.GetCultureInfo("es-MX"),System.Globalization.DateTimeStyles.None).ToString("YourFormat")