I need bit(64) representation of current epoch (the operations I need should be much easier in bits), so

SELECT extract('epoch' from CURRENT_TIMESTAMP)::bit(64)

But this gives me

ERROR: cannot cast type double precision to bit

What am I doing wrong here?

UPD: In fact, I understood I should do it the other way, but the ERROR itself is still very strange for me.

  • Can you explain what kind of operation you have in mind? I can't think of anything that could be done with a timestamp that would be easier with a bit representation. – a_horse_with_no_name Jan 25 at 17:39
  • @a_horse_with_no_name I just produce the key for table pagination. First bits are about time and the rest is my own ID. But it seems ok to just use INT instead of truncated DOUBLE as first 32 bits. – Ximik Jan 25 at 18:01
  • The answer can be found on stackoverflow. – Ximik Feb 4 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.