I am populating a list “results” with dates. In a query result I am getting a set of values .. where date value is in this format ..
20120510000000000
In my code, I am doing the following..
query = service.GetData();
List<String> results = new List<String>();
foreach (var item in query)
{
results.Add(item.InDate);
//This is in this format - 20120510000000000
//Here I want to convert to mm-dd-yyyy
}
return results;
I would like to convert the above date format into “mm/dd/yyyy” and post it to “results” list.
If the date is guaranteed to be in the [year][month][day][hour][minute][second][millisecond] format (looks like it), you can use a simple string manipulation:
if you want it in a DateTime object, you can use the DateTime.ParseExact method: