How to Filter Column based on first 5 dates

Hi ,


How i can filter dt to get the date between 1-MM and 5-MM in current month ?

i am using filter to get the date in current month but i am not able to get only date between 1 to 5.

could anyone help me please

Thank you

Hi,

In filter condition keep that dates detween 1 to 5 by using conditon from date =1-MM or date =2-MM and etc…

there is no way to create range between 1 to 5 ?

you can try by using linq query

can you please provide the query ?

can you please provide your excel ?

Sure

Hi,

Can you try the following expression?

dt = dt.AsEnumerable.Where(Function(r) DateTime.Parse(r("DateColumn").ToString)>=new DateTime(Now.Year,Now.Month,1) AndAlso DateTime.Parse(r("DateColumn").ToString)<new DateTime(Now.Year,Now.Month,6)).CopyToDataTable

Regards,

2 Likes

Thank you @Yoichi

it is working

1 Like

sorry , when there is no matching date i get this error

image

Hi,

Can you try as the following?

arrDr =dt.AsEnumerable.Where(Function(r) DateTime.Parse(r("DateColumn").ToString)>=new DateTime(Now.Year,Now.Month,1) AndAlso DateTime.Parse(r("DateColumn").ToString)<new DateTime(Now.Year,Now.Month,6)).ToArray

Note: arrDr is DataRow Array type.

Regards,

1 Like

Thank you @Yoichi working

1 Like

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