0
点赞
收藏
分享

微信扫一扫

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

奋斗De奶爸 2023-03-03 阅读 51


// 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 条评论