Filter dt based on Month

Give a try at:
dtFiltered =

(From d in dtData.AsEnumerable
Let ds = d("Bot Modified Date").toString.Trim
Let dp = CDate(ds)
Where dp.ToString("MM-yyyy").Equals(now.AddMonths(-1).ToString("MM-yyyy"))
Select r = d).CopyToDataTable

Handling empty result:

When DateParsing has to be adapted:

Kindly note:

  • we used the toString(“MM-yyyy”) trick to simply the month check
  • still the of doing date compares on DateTime DataType base is valid and should be applied
1 Like