Selecting Latest Year and Latest Month, and Oldest Year and Oldest Month(LINQ)

Hi,

Can you try the following expression?

Oldest

dt.AsEnumerable.OrderBy(Function(r) new DateTime(Int32.Parse(r("Year").ToString),Int32.Parse(r("Month").ToString),1)).Select(Function(r) r("Year").ToString+":"+r("Month").ToString).First()

Latest

dt.AsEnumerable.OrderBy(Function(r) new DateTime(Int32.Parse(r("Year").ToString),Int32.Parse(r("Month").ToString),1)).Select(Function(r) r("Year").ToString+":"+r("Month").ToString).Last()

Regards,

1 Like