How do I parse a Date to custom format?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
So I am using an SQL Data Reader to get date information from my database but its returning a date/time in ISO format.
This is what I have so far to try and convert the date but its not working :(
while (timelineReader.Read())
{
string devStart = Convert.ToDateTime(timelineReader["startDate"]).ToString("dd/MM/yyyy");
string devEnd = Convert.ToDateTime(timelineReader["endDate"]).ToString("dd/MM/yyyy");

timeline = new Timeline();

timeline.endDate = DateTime.ParseExact(devEnd, "dd/MM/yyyy", null);
timeline.startDate = DateTime.ParseExact(devStart, "dd/MM/yyyy", null);

//add the new record to array
timelineList.Add(timeline);
}

The date format this code is returning is: 2012-07-25T00:00:00
However I would like it to be: 2012,07,25
How can this be done?
Thank You :)

View the full article
 
Back
Top