Skip to content
Advertisement

PostgreSQL – How to format an int as an hexa

What’s a short/simplest way of formatting an int to an hexa, with leading zeroes? For example I need to format:

My query needs many of these conversions I would appreciate a short piece of code instead of a verbose one. Just need to deal with positive numbers.

Advertisement

Answer

I’m not sure it’s the shortest way but at least I found one:

as in:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement