0

I have a table where I have 2 fields that represent unix epoch timestamp hex example "62508501", "624F645F". They are strings data type. I want to be able to compare the 2 timestamps.

Can I straight up compare these string:

ts1_hex_string > ts1_hex_string

  • Would this be an accurate representation of comparing the actual data/time timestamps?
  • If not, what is the easiest way to compare in SQL or python?
PrueWho
  • 53
  • 4
  • 1
    You can only compare numbers as strings if they're the same number of digits. For instance, `"60" > "100"` is true. – Barmar Apr 15 '22 at 00:09
  • 1
    The best way is to convert the hex to a number and then compare that. The fact that they represent timestamps is irrelevant, they're just numbers. – Barmar Apr 15 '22 at 00:10
  • 1
    you seem to be dealing with integer seconds since the epoch, so simply `int("62508501", 16) > int("624F645F", 16)` for example should do. – FObersteiner Apr 15 '22 at 09:59

0 Answers0