I am working on a automation where I am extracting a table which has 8 columns.
The problem is that I want to filter this datatable besed on time column.
I want only rows which were created 1 hour back.
for example.
In the above screen shot.
the time column has multiple rows and Suppose the current time is 11:00
so bot should keep 7 rows which is starting with 10:xx because it qualifies 1 hour criteria . the time is 24 hour format.
Please help
filteredDataTable= (From row In YourDataTableVariable.AsEnumerable()
Let timeStr = row.Field(Of String)("Time")
Let time = DateTime.ParseExact(timeStr, "HH:mm", System.Globalization.CultureInfo.InvariantCulture)
Where time >= DateTime.Now.AddHours(-1)
Select row).CopyToDataTable()
filteredDataTable = (From row In dt.AsEnumerable()
Let timeStr = row.Field(Of String)("Time")
Let time = DateTime.ParseExact(timeStr, "HH:mm", System.Globalization.CultureInfo.InvariantCulture)
Where time >= DateTime.Now.AddHours(-1)
Select row).CopyToDataTable()