Hi, i am trying to filter a DT where i have a column named as Date where i need to get only the datas from past 7 days.
thanks
Hi, i am trying to filter a DT where i have a column named as Date where i need to get only the datas from past 7 days.
thanks
Hi,
Sequence:
- Assign: filteredDataTable = dataTable.Clone()
- For Each Row: row in dataTable
- If: row(“Date”) >= DateTime.Now.AddDays(-7)
- Add Data Row: row to filteredDataTable
- Use filteredDataTable as needed
Thanks
It takes a long time
i dont want using for each loop
Hi,
Use an Assign activity to create a new DataTable variable to store the filtered results. Let’s call it filteredDataTable
filteredDataTable = yourDataTable.Select(“[Date] >= #” + DateTime.Now.AddDays(-7).ToString(“MM/dd/yyyy”) + “#”).CopyToDataTable()
Thanks
Hi @Mohammad_Irfan ,
Could you check the below Expression :
DT.AsEnumerable.Where(Function(x)CDate(x("Date").ToString).Date>=Now.AddDays(-7).Date).CopyToDatatable
We might receive error on CDate()
but it depends on the format or the values the date column will hold. Do check and let us know if it doesn’t work as expected.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.