VB and VBA Users Source Code: Converting the SQL/Sybase timestamp datatype to a hex string
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Converting the SQL/Sybase timestamp datatype to a hex string
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Friday, June 11, 2004
Hits:
1400
Category:
Database/SQL/ADO
Article:
The code below takes a variant containing a Timestamp field and converts it to a hex string. 'Purpose : The code below takes a variant which contains a sybase/SQL timestamp field ' and converts this into a hexidecimal string 'Inputs : avTimeStamp A variant containing the timestamp 'Outputs : Returns the hexidecimal representation of a timestamp field 'Author : Andrew Baker (copyright www.vbusers.com) 'Date : 31/Jan/2002 'Notes : It is generally considered easier to convert the timestamp to a SQL 'int' datatype ' in the fetch SQL. 'Revisions : Function ConvertTimeStampToHex(avTimeStamp As Variant) As String Dim sHexChar As String Dim sResult As String Dim i As Long If IsArray(avTimeStamp) Then For i = LBound(avTimeStamp) To UBound(avTimeStamp) 'Convert the character to hex sHexChar = Hex(avTimeStamp(i)) If Len(sHexChar) = 1 Then 'Pad the hex string sHexChar = "0" & sHexChar End If sResult = sResult & sHexChar Next Else sResult = "??" End If BinToHex = "0x" & sResult End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder