Problem with decimal portion of seconds in date
Posted on 2008-10-27
I am working on a VB6 - ADO program that ties in with some stored proceedures (developed by a third party). The problem that I am running into is that when the stored proceedure populates a datetime field it records the seconds to 3 decimal points, for example 09/01/2008 09:29:25.233. When I use visual basic to retrieve this field and then try to run a query using the result it seems like it is cutting off the decimal portion of the seconds and giving me an empty record set.
SQL Server table:
Test 09/01/08 09:29:25.233
Using VB6 and an ADO Query
sqltext = "Select * from myTable where field1 = 'Test'"
myRS.open sqltext, myConnection, adOpenDynamic, adLockOptimistic
#At this point one record is returned, so I note the modify datetime
tmpdte = myRS!ModifyDateTime
#now we run a query using the returned value
sqltext = "Select * from myTable where ModifyDateTime = '" & tmpdte & "'"
myRS2.open sqltext, myConnection, adOpenDynamic, adLockOptimistic
#this returns no records, however if I change the value in the modifydatetime field to 09/01/08 09:29:25 then it works fine.
Does anyone have any ideas how to get around this.