Filter dates to the end of the month

Hi, the robot filters out dates older than today:

var1.AsEnumerable().Where(Function(row) DateTime.ParseExact(row(“Expiration date”).ToString(), “yyyy-MM-dd”, System.Globalization.CultureInfo.InvariantCulture) <= DateTime.Today.Adddays(45) AndAlso DateTime.ParseExact(row(“Expiration date”).ToString(), “yyyy-MM-dd”, System.Globalization.CultureInfo.InvariantCulture) >= DateTime.Today).CopyToDataTable()

Now I need it to filter dates to the end of the month in the same way, e.g. all dates that are until the end of August, e.g. August 10, August 11, July 15, etc. Please help.

Hi @sullivanne

Can you be more brief

@sullivanne

var1.AsEnumerable().Where(Function(row) 
    DateTime.ParseExact(row("Expiration date").ToString(), "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture) <= 
    New DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.DaysInMonth(DateTime.Today.Year, DateTime.Today.Month))
).CopyToDataTable()

Please try this linq query,Hope this works for you

Thank You, but I need these exact dates:
From today, filter everything that is until the end of August.
Until the end of September.
Until the end of December.
Until the end of January (New Year’s).
Including the last day of the month.
So if I need all dates until the end of September, I filter, for example: 02.09, 03.09, 15.09 and 30.0 etc. I don’t know if this is clear. I don’t want just the last day of the month, but all dates that are until the end of a given month.