DataTable 获取列中日期最大值 最小值 比较日期

阅读 51

2023-03-03


// Actual Code
DataColumn col = dt.Columns[0]; // Call this the one you have

DataTable tbl = col.Table;

var first = tbl.AsEnumerable()
.Select(cols => cols.Field<DateTime>(col.ColumnName))
.OrderBy(p => p.Ticks)
.FirstOrDefault();

var last = tbl.AsEnumerable()
.Select(cols => cols.Field<DateTime>(col.ColumnName))
.OrderByDescending(p => p.Ticks)
.FirstOrDefault();



https://stackoverflow.com/questions/8299139/how-to-find-the-max-in-a-datacolumn-of-datetime

 

精彩评论(0)

0 0 举报