Reputation: 812
In the datatable, column contains values:
Column1
-------
2013-03-26 11:40:24.623
2013-03-26 11:20:24.623
2013-03-26 11:00:24.623
2013-03-26 10:40:24.623
2013-03-26 10:20:24.623
2013-03-26 10:10:24.623
...
I need to get list containing distinct date parts.
I tried:
List<DateTime> dateList = (
from row in dt.AsEnumerable()
select row.Field<DateTime>("TimeStamp").Date
).Distinct().ToList<DateTime>();
It treats each value as distinct. How to avoid time part?
Upvotes: 2
Views: 1789
Reputation: 148150
You can use Enumerable.Distinct
dt.AsEnumerable().Distinct(r => row.Field<DateTime>("TimeStamp").Date);
Upvotes: 3