Filter Date > 20th

Dear,

How May i Filter Date > 20th of the now.month and now.year?

Thanks alot.
Expl.

exp.xlsx (10.7 KB)

after using read range to read the excel table to dt variable,
assign this to dt:

dt.AsEnumerable.Where(Function(x) not String.IsNullOrEmpty(x("Date").ToString)).CopyToDataTable.AsEnumerable.Where(function(y) cdate(y("Date").ToString).Day > 20).CopyToDataTable

image

You can calculate the 20th of Now.Month and Now.Year as Now.AddDays(20-Now.Day)

(From r In dt
		Let strDate = r("Date").ToString
		Where Not String.IsNullOrWhiteSpace(strDate) AndAlso Convert.ToDateTime(strDate) > Now.AddDays(20-Now.Day)
		Select r
).CopyToDataTable
1 Like

it is working but only for one month thanks.

if you also want to only include now.month and now.year do this

dt.AsEnumerable.Where(Function(x) not String.IsNullOrEmpty(x("Date").ToString)).CopyToDataTable.AsEnumerable.Where(function(y) cdate(y("Date").ToString).Day > 20 and cdate(y("Date").ToString).Month = now.Month and cdate(y("Date").ToString).Year = now.Year).CopyToDataTable

1 Like

before

after
image

1 Like

Thanks alot For the help.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.