I have date represented as integer like 20140820
and I want to parsing it as datetime, like 2014.08.20.
Do I need to parse each integer value (2014)(08)
Try This :-
string time = "20140820";
DateTime theTime= DateTime.ParseExact(time,
"yyyyMMdd",
CultureInfo.InvariantCulture,
DateTimeStyles.None);
OR
string str = "20140820";
string[] format = {"yyyyMMdd"};
DateTime date;
DateTime.TryParseExact(str,
format,
System.Globalization.CultureInfo.InvariantCulture,
System.Globalization.DateTimeStyles.None,
out date))
now date
variable will have required converted date of string '20140820'