0

How can I get this date format? yyyy/MM/dd, I currently receive this format at exit 14.08.2017

This is my code:

dataGridView1.Rows[n].Cells[0].Value = DateTime.Parse(ev.Attribute("Start").Value).ToShortDateString();

Please look at my code, in other similar cases, I could not find the same situation..

Thanks everyone

enter image description here

  • I tried that, the same format is coming out again.. –  Aug 14 '17 at 08:14
  • Have you tried `ToString("yyyy/MM/dd");` Is that what you want? – mortb Aug 14 '17 at 08:17
  • Try with DateTime.ParseExact(ev.Attribute("Start").Value,"yyyy/MM/dd",null); – D Ie Aug 14 '17 at 08:38
  • Thanks for the answers, with ToString("yyyy/MM/dd"); I tried not to work. This second comment shows me a mistake:"FormatException was unhandeld" –  Aug 14 '17 at 09:20
  • "When converting a string to Datetime, parse the string to take the date before putting each variable into the datetime object." –  Aug 14 '17 at 09:40
  • This is a solution: DateTime.Parse(ev.Attribute("Start").Value).ToString(@"yyyy\/MM\/dd"); –  Aug 14 '17 at 11:22

0 Answers0