Reputation: 6541
Just wondering how I can convert the following string into a datetime 111222, at the moment it is telling me that this is not a valid datetime value..
Upvotes: 0
Views: 1560
Reputation: 69372
You can use the DateTime.ParseExact method and supply the format your input is in.
Edit - added code:
DateTime dt = DateTime.ParseExact("111222", "yyMMdd", CultureInfo.InvariantCulture);
Console.WriteLine(dt.ToString());
Upvotes: 3