Q:

compare datetime values just by date

i wish to compare to datetime values just by date, not by hour. How can i do so ?
I want to remove some values that are outside an interval selected by me :
if (DateTime.Compare(DateTime.Parse(t.Rows[i][1].ToString().Trim()), dateTimePicker1.Value) < 0 || DateTime.Compare(DateTime.Parse(t.Rows[i][1].ToString().Trim()), dateTimePicker2.Value) > 0) 
/*remove comand*/

A:

Use the DateTime.Dateproperty for this, since this contains only the date part of the DateTimeobject.
if (DateTime.Compare(DateTime.Parse(t.Rows[i][1].ToString().Trim()).Date,
    dateTimePicker1.Value.Date) < 0 || DateTime.Compare(DateTime.Parse(t.Rows[i]1].ToString().Trim()).Date, 
    dateTimePicker2.Value.Date) > 0)

A:

Be also aware of Utc and Locale issue.
For me it's important to do all compare in Utc !
So do something like
Datetime d1, d2;
d1 = d1.toUniversalTime().Date;
d2 = d2.toUniversalTime().Date;
if(DateTime.Compare(d1, d2))....

A:

DateTime d1, d2';

...

// following will compare by date and time both
d1 == d2

// following will compare by date only
d1.Date == d2.Date

