TO_HEX

The TO_HEX function converts data from the binary data type to a character data type in which the character is represented in hexadecimal format.

Syntax

TO_HEX (binary_expression)

Remarks

The argument binary_expression evaluates to the integer to be converted to a hexadecimal value.
Returns a VARCHAR representing the hexadecimal equivalent of a number.

Example

SELECT TO_HEX (‘Binary’::binary(2));

This returns:

8046