I have a date / time format, for example: "1-Mar-13 92230" According to this document and this link the format is as follows: "d-MMM-yy Hmmss", because:
Day is single digit, 1-30 Month is 3 letter abbreviation, Jan/Mar etc. Year is 2 digits, eg 12/13 Hour is single digit for 24 hour clock, eg 9, 13 etc. (no 09) Minute is standard (eg 01, 52) Second is standard (eg 30, 02)
I try to run the following code in my program, but I continue to receive the error message "String was not recognized as a valid DateTime."
string input = "1-Mar-13 92330"; var date = DateTime.ParseExact(input, "d-MMM-yy Hmmss", System.Globalization.CultureInfo.CurrentCulture);
Please help, I'm not too familiar with DateTime conversions, but I donβt see where I made a mistake here. Thanks!
UPDATE: Is it because time cannot be parsed without colons in between? (e.g. 1-Mar-13 9:22:30 receives parsing, but I have an external data source that cannot be rewritten from Hmmss to H: mm: ss)
John
source share