I have a list of dates as below
List<string> nameList = new List<string>();
nameList.Add("20120618PM");
nameList.Add("20120622PM");
nameList.Add("20120622AM");
nameList.Add("20120628PM");
nameList.Add("20120702PM");
nameList.Add("20120629AM");
nameList.Add("20120629PM");
I want to find MAXDATE and MIN DATE from the list .Please let me know how can i proceed.
Regards,
Channa
If the date format is yyyyMMdd then is is sortable as strings even with AM/PM
If you have a year plus hours/minutes and AM/PM then you must parse to DateTime. I recommend parsing regardless, as suggested in other answers.