Convert string to specific format in date

3

I have a string "sex, nov 6" and need to convert to DateTime .

I'm doing it this way:

DateTime datetime =
DateTime.Parse(gridT.Columns[e.ColumnIndex].HeaderText.ToString());

But it is not working.

How can I do this conversion?

    
asked by anonymous 06.11.2015 / 12:42

1 answer

5

You need to exact conversion , but if date is not in the expected format, lascou:

DateTime.ParseExact("sex, nov 6", "ddd, MMM d", new CultureInfo("pt-BR"))

See working on dotNetFiddle .

    
06.11.2015 / 12:54