0

i have a string which is "26052014153850" it is in the format of date month year hour minute second. i want to convert this to date and time format but its showing string is not recognized as valid date and time

string result ="26052014153850";
     DateTime dt = DateTime.ParseExact(result, "dd/MM/yyyy/HH/mm/ss", CultureInfo.InvariantCulture);
user2380844
  • 277
  • 4
  • 15
  • 30
  • possible duplicate of [convert datetime to date format dd/mm/yyyy](http://stackoverflow.com/questions/5050102/convert-datetime-to-date-format-dd-mm-yyyy) – Ram Singh May 27 '14 at 05:09

1 Answers1

4
 DateTime dt = DateTime.ParseExact
               (result, "ddMMyyyyHHmmss", CultureInfo.InvariantCulture);

The format of the string representation must match the specified format exactly.
Read this for more from MSDN.

Farhad Jabiyev
  • 26,014
  • 8
  • 72
  • 98