-2
I have a problem with a conversion using the code below:
string vcto = "29/01/2018";
DateTime data;
Boolean resp = DateTime.TryParse(vcto, out data);
if (resp == false)
{
MessageBox.Show("ERRO NA CONVERSAO");
}
He is returning false
. but the date is correct.
I don’t have access to the machine that’s running the code, I just checked via log. In my development machine works perfectly.
What can do the TryParse()
fail? The date is correct.
The input is different from the one reported in the question?
– Leandro Angelo
Can you see which language the machine is? It may be set up in a different language, probably English. You can test this by changing the month by the day in input.
– Júlio Neto
Why not use : Convert.Todatetime() ?
– Vinícius
Friend check is not the culture of your server, I’ve had problems with date conversion for this reason.
– Maycon F. Castro
@Viniciusmatos because it would be a mistake to do this, it is partially correct.
– Maniero