Hi,
I'm trying to subtract 2 dates.: currentdate and a maxDate value that I have. If the difference between the 2 dates is 180 days then I want a messagebox to show up.
Here's the code I have so far. Everything works except for the "currentDate - maxDate > 180" part. I get an error on that part.
Code:
Dim maxDate As DateTime = "1/1/1900"
Dim x As Integer = 0
Dim currentDate As DateTime = DateTime.Now
For x = 0 To Me.DataGrid1.VisibleRowCount - 1
Try
If Not IsDBNull(DataGrid1.Item(x, 2).ToString) Then
If CDate(DataGrid1.Item(x, 2)) > maxDate Then
maxDate = (DataGrid1.Item(x, 2))
End If
End If
Catch ex As Exception
End Try
Next
If currentDate - maxDate > 180 Then
Msgbox("error")
End If