|
-
Feb 3rd, 2005, 06:07 AM
#1
Thread Starter
Member
SQL problem: Converting timestamp field into double value
I'm writing a VB app which sends an SQL statement to MS SQL Server:
strSQL = "select * from systemevents where timestamp >= " + CStr(LastEventTimestampRead) + " ORDER BY timestamp"
strSQL = the SQL statement
timestamp = field with date and time value, in date and time format.
LastEventTimestampRead = double variable from external source, representing a time value.
How do I convert the timestamp field value into a DOUBLE type value within the SQL statement, so I can compare it with the LastEventTimestampRead variable? I tried CDbl but that's an Access command that's not compatible with SQL Server.
Thanks.
Last edited by Dr.Rock; Feb 3rd, 2005 at 07:04 AM.
-
Feb 3rd, 2005, 11:33 AM
#2
Re: SQL problem: Converting timestamp field into double value
Is the datatype of your TimeStamp column datetime, smalldatetime or timestamp?
TimeStamp columns have nothing to do with date and/or time. It is an 8 byte binary value generated by sql server. You should only be checking for equality with timestamp columns. Also, I believe it is impossible to pass timestamp values between SQL Server and VB via strings. Use the ADO Command object with a Parameter instead.
If your timestamp column is datetime or smalldatetime, there is no reason to convert it to double.
VB Code:
strSQL = "select * from systemevents where timestamp >= '" & Format$(LastEventTimestampRead,"yyyymmdd") & "' ORDER BY timestamp"
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
|