I had data in data table. Attach is the excel file whose data i am storing in datatable. I want to filter data using 3 fields.
1- Field Name - Received Date - Want to filter data using last week data i mean today -7. Date is stored in variable.
2- Field Name - Eng Vendor - Value is PEARCE SERVICES INC
Book1.xlsx (14.4 KB)
Hi,
It seems just 2 fields to filter in your post. However,how about the following?
arrDr = dt.AsEnumerable.Where(Function(r) DateTime.TryParse(r("Received Date").ToString,New DateTime) AndAlso DateTime.Parse(r("Received Date").ToString).Date <=Today AndAlso DateTime.Parse(r("Received Date").ToString).Date >=Today.AddDays(-7) AndAlso r("Eng Vendor").ToString="PEARCE SERVICES INC").ToArray
Sample : As there is no record which has within 7 days in received date, i modified data a little.
Sample20230502-3L.zip (14.7 KB)
Regards,
arrDr = dt.AsEnumerable.Where(Function(r) DateTime.TryParse(r(“Received Date”).ToString,New DateTime) AndAlso DateTime.Parse(r(“Received Date”).ToString).Date <=Today AndAlso DateTime.Parse(r(“Received Date”).ToString).Date >=Today.AddDays(-7) AndAlso r(“Eng Vendor”).ToString=“PEARCE SERVICES INC”).ToArray
Hello sir i am having weekstart date and weekend date which is previous week date and when i am passing those variable in above query. it showing an error to me. how to fix that.
Hi,
Are WeekEndDate and WeekStartDate DateTime type? If so, it’s unnecessary to add .ToString.
If they are string type, it’s necessary to convert to DateTime type using CDate or DateTime.Parse, for example.
Regards,
Hi,
Can you check content of WeekEndDate and WeekStartDate at Locals panel when error occurs? Is it empty string?
Regards,
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.