The Date property of the DateTime structure will give you a date, but will always have a time component representing midnight ("00:00:00"). If you start with a line, you can work with something like this:
DateTime d = DateTime.Parse("2/27/2013 4:18:53 PM").Date;
Just make sure that you are comparing on DateTime objects (i.e. omit all use cases of ToString() ).
Alternatively, you can format the date in "sortable" format:
string d = DateTime.Parse("2/27/2013 4:18:53 PM").ToString("s");
or
string d = yourDateTime.ToString("s");
In the above case, d will be 2013-02-27T16:18:53 . When sorted alphabetically, the rows will be in chronological order.
Cα΄ΚΚ May 01, '13 at 21:20 2013-05-01 21:20
source share