0

I have written a query to retrieve a row from a table in SQL Server. I am using pyodbc and python 3.7 here.

I am getting the following:

(18, 3, 1, 'test', 'test', None, Decimal('0.0000'), Decimal('0.0000'), 0, 0, b'\x00\x00\x00\x00\x0f\xe7\xaco')
The last value b'\x00\x00\x00\x00\x0f\xe7\xaco' is the timestamp of the row which looks like follows in the database "0x000000000FE7AC6F".

I want to be either able to retrieve the timestamp as is or be able to convert b'\x00\x00\x00\x00\x0f\xe7\xaco' into the proper timestamp value before calling another query which uses the value.

Ayush Vatsyayan
  • 2,498
  • 21
  • 27

1 Answers1

0

Since you are using python3, the conversion is relatively easy.

s=b'\x00\x00\x00\x00\x0f\xe7\xaco'
'0x'+s.hex().upper()

has output

'0x000000000FE7AC6F' 
Kapil
  • 234
  • 4
  • 9