Lowercase mm
means minute, use MM
DateTime mydate = DateTime.ParseExact(datetoconvert,"dd/MM/yyyy",System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat);
If you want to output it as 30/Mar/2017
(different topic):
string result = mydate.ToString("dd/MMM/yyyy", CultureInfo.InvariantCulture);
But note that /
has a special meaning too(in Parse
and ToString
). It will be replaced with your current cultures date-separator which seems to be /
but fails with a different. You can avoid it by specifying CultureInfo.InvariantCulture
or by masking it by wrapping it with apostrophes:
DateTime mydate = DateTime.ParseExact(datetoconvert,"dd'/'MM'/'yyyy",System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat);