Using an SQL timestamp value in an SQL Execute query

I am attempting to select data from an SQL Server database and using a timestamp in the where clause and having some challenges.

I am taking a 2-step process:

  1. Select from a DB table the most recent timestamp. This is a binary(8) data-typed field that contains an actual timestamp value. E.G 0x000000001EBED38E
  2. The selected value is now assigned to $LastTimestamp and contains ‘Base64 encoded data’ - it actually looks like “AAAAAB6+044AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=”
  3. Use this timestamp value in an SQL Select statement.

Example, stripped back version of the SQL query is:

SELECT TOP 1000 * FROM MyDB where MyDB.timestamp >= $LastTimestamp

I’ve tried a few things, such as decoding/encoding all with no success. Often results in a message that looks like:

“Unable to decode base64 value, Reason: Bad Base64 input character decimal 0 in array position 0, Resolution: Make sure the argument is valid base64”

Question - how can i use the binary(8) timestamp retrieved in one snap as part of the where clause in another snap?