Hello everyone, I've been working on this problem for a couple days but I am making no progress so I decided to check here and see if I could get some help.
I am filling my dataset with the following query.
Once the dataset is filled I would like to run a filter on the dataset but I'm not sure how to go about it. I need to compare the current date to taskInfo.LastCompleted date if the number of days between those two dates is equal to or greater then taskInfo.interval display that row in the dataset.
I can fill the dataset using the above SELECT statement and then loop through the dataset with the following code and then fill another dataset with the appropriate data but I would rather not do that if I can help it.
I am filling my dataset with the following query.
VB.NET:
SELECT TaskInfo.taskId, TaskInfo.TaskName, TaskInfo.EquipmentId, TaskInfo.Description, TaskInfo.Interval, TaskInfo.LastCompleted,
EquipmentInfo.equipmentId AS Eq_Id, EquipmentInfo.EquipmentName
FROM TaskInfo INNER JOIN
EquipmentInfo ON TaskInfo.EquipmentId = EquipmentInfo.equipmentId
Once the dataset is filled I would like to run a filter on the dataset but I'm not sure how to go about it. I need to compare the current date to taskInfo.LastCompleted date if the number of days between those two dates is equal to or greater then taskInfo.interval display that row in the dataset.
I can fill the dataset using the above SELECT statement and then loop through the dataset with the following code and then fill another dataset with the appropriate data but I would rather not do that if I can help it.
VB.NET:
Public Function getCurrentTask() As DataSet
Dim ds As New DataSet 'first dataset to fill with data
Dim result As TimeSpan 'variable to store the timespan between two dates
Dim storedDate As Date 'date in datarow
Dim currentDate As Date 'current date
Dim ds2 As DataSet 'dataset to hold filtered data
ds = getTaskList() 'call to a function to fill the first dataset
For Each row As DataRow In ds.Tables("TaskInfoList").Rows
Then
storedDate = row.Item("LastCompleted") 'setting value to variable
currentDate = Date.Today 'setting value to variable
result = currentDate - storedDate 'setting value to variable
If result.Days >= row.Item("interval") Then
Console.WriteLine("Result: " & result.Days & " | " & "Interval: " & row.Item("interval") & " | " & row.Item("TaskName") & " | " & "Last Completed: " & row.Item("LastCompleted") & " | " & "Today: " & Date.Today)
End If
Next
Return ds2