Hi All
Been cracking up with this one for a few days and have no idea why it is doing it. I have a database table which stores the schedules for inspections. When an operator signs into the system a snapshot is displayed showig the user the inspections for today, tomorrow, this week and overdue. The strange thing is, none of the date selections are working correctly.
The likes of today, 24/08/2005, should return 0 overdue, 0 for tomorrow, 0 for today and 0 for this week, as the only inspection in the table is for the 01/09/2005. But when the queries are run, it returns 1 inspection overdue which isnt correct. The field in the table is setup as a date field etc.
Code as below
Been cracking up with this one for a few days and have no idea why it is doing it. I have a database table which stores the schedules for inspections. When an operator signs into the system a snapshot is displayed showig the user the inspections for today, tomorrow, this week and overdue. The strange thing is, none of the date selections are working correctly.
The likes of today, 24/08/2005, should return 0 overdue, 0 for tomorrow, 0 for today and 0 for this week, as the only inspection in the table is for the 01/09/2005. But when the queries are run, it returns 1 inspection overdue which isnt correct. The field in the table is setup as a date field etc.
Code as below
VB.NET:
Dim connection As New OleDbConnection(gsConnection)
Dim gSql As String
Dim null As System.DBNull
Dim pickdate As Date = insDate
Dim sdate As String
pickdate = Format(pickdate, "dd/MM/yyyy")
sdate = pickdate
gSql = "Select LocationName, InspectionDate, Inspector from Schedule where (((Schedule.InspectionDate) < #" & sdate & "#))"
connection.Open()
Dim adapter As New OleDbDataAdapter(gSql, connection)
Dim dataset As New DataSet
adapter.Fill(dataset)
adapter.Dispose()
connection.Close()
overdue = dataset.Tables(0)
Dim count As Integer
count = overdue.Rows.Count()
If count <> 0 Then
lblOverdue.Text = count & " inspections are overdue."
'Display_SnapShot()
Else
lblOverdue.Text = "0 inspections are overdue."
dgSnapshot.DataSource = null
End If