Excel Filter Column

Hi,

I have a Excel sheet containing reports. On that sheet, there is a column named as ‘Assigned Date’. I want to filter that column based on week(i.e. From last Tuesday to Monday(Current week)).
Please help me on this.

Thanks in advance!!

@Abishek
Can you explain in generalised format . In general how you want to filter. Suppose if you run the same code next week then you want to filter the data which contains current week date. i.e last 7 days right.

Your excel sheet date column Date is in which format

Regards,
Mahesh

@Abishek

dt1=(From p In dt.Select
where DateTime.Now.DayOfYear-(DateTime.ParseExact(p.Item("Assigned Date").ToString,"dd-MM-yyyy",System.Globalization.CultureInfo.InvarientCulture).DayOfYear)>=0 and DateTime.Now.DayOfYear-(DateTime.ParseExact(p.Item("Assigned Date").ToString,"dd-MM-yyyy",System.Globalization.CultureInfo.InvarientCulture).DayOfYear)<=7 and DateTime.Now.Year=(DateTime.ParseExact(p.Item("Assigned Date").ToString,"dd-MM-yyyy",System.Globalization.CultureInfo.InvarientCulture).Year
Select p).ToArray.CopyToDataTable

dt1- Filtered Data
dt-Original Data.

Sorry if it throws any exceptions, because I have not tested the code :grinning:

Regards,
Mahesh

@MAHESH1

If i run the same code next week, it should filter from last week Tuesday to this week Monday (7 Days).
Date Format: dd-mm-yyyy

Thanks

@Abishek

Try the code and let me know whether it is working or not

Regards,
Mahesh

what is the type of dt1

i have a situation a like i need only present week dates (only availible if excel sheet contains one date of present week then return only one) , is there any solution.
please help