I have an input excel with the following data
Received date Name
10/23/2019 ABC
06/29/2017 CDF
11/10/2024 EFG
SCENARIO :
I want to filter the input records and fetch records of over 2 years when compared to current date .
Can someone please help me with the syntax ?
Hi @Ragavi_Rajasekar
you can use below linq query to filter and it will compared the date with 2 years before date
dt.AsEnumerable().Where(Function(row) DateTime.Parse(row(“Received date”).ToString()) < DateTime.Now.AddYears(-2)).CopyToDataTable()
I hope this will resolve your issue
Thank You
Akash Javalekar
1 Like
SorenB
3
Hello @Ragavi_Rajasekar
You should be able to filter data by using .Select option on you Datatable after reading the Excel file.
dt_ExcelData.Select("[Received date] > '"+Date.Now.AddYears(-2).ToString("MM/dd/yyyy")+"'")
Regards
Soren