I have the value of a date in a DateEdit
which the default value is DD/MM/YYYY
and I need to convert it to a string
format YYMMDD
to show it in a TextBox
since it will define the name of a task on that date.
I have this code using the ParseExact()
method:
DateTime fecha = DateTime.ParseExact(edtStartDate.Text, new[] { "YYYYMMDD", "YYMMDD" }, CultureInfo.InvariantCulture, DateTimeStyles.None );
tbSubject.Text = fecha.ToString("YYMMDD");
But it throws an exception that does not recognize it as a valid string
and I can not find what I'm doing wrong:
String was not recognized as a valid DateTime.