|
-
Nov 25th, 2007, 01:37 AM
#1
Thread Starter
Junior Member
VB.NET to SQL Express Date Comparison
Help. I am at this one for about three hours now. I have narrowed the problem down to the date comparison on the end of the SQL statement.
If I remove the WHERE, the expected data is returned for all dates. I don't beleive that the dates are comparing correctly but from the looks of it, they should be.
Can anyone help ? I would greatly appreciate it. Stuck. See code below.
Private Sub LoadDataSet()
'Initialize a new instance of the data access base class
objData = New Globals
Try
'Get all Data in a Dataset Object
objData.SQL = _
"SELECT o.OrderID, o.ProductID, o.UnitPrice, o.Quantity,ord.OrderID, ord.TotalSale, ord.SalesTaxAmt, ord.OrderDate " & vbCrLf & _
"FROM [Orders] ord INNER JOIN OrderDetails o ON ord.OrderID = o.OrderID " & vbCrLf & _
"WHERE CAST(CONVERT(VARCHAR(10), ord.OrderDate, 101) AS DATETIME) = CAST(CONVERT(VARCHAR, GETDATE(), 101) AS DATETIME)"
objOrdersDS = New DataSet
Call objData.FillDataSet(objOrdersDS, "Orders")
Catch ex As Exception
MessageBox.Show(ex.Message, strAppTitle)
Finally
'Cleanup
objData.Dispose()
objData = Nothing
End Try
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|