Rows from last 7 days only

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.



- 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

It takes a long time
i dont want using for each loop


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()


Hi @Mohammad_Irfan ,

Could you check the below Expression :


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.