ANSI | DB2 | SQL/DS | XDB |
---|---|---|---|
X | X |
Returns a string that is the hexadecimal representation of x, where the parameter value x can be any value other than a long string. The format appears below:
HEX(x)
The result is a string of hexadecimal digits, with each consecutive pair of digits representing a byte of the argument, so that the length is twice the length of the argument. In DB2 compatibility mode, bytes are swapped for smallint, integer and date fields. In XDB mode, PC Intel format is used for smallint, int and date fields.
If the location sort sequence is EBCDIC, character fields display in HEX based upon the EBCDIC code page. Also, performing a HEX function on a date field in DB2 mode shows the result as if stored in DB2 format instead of XDB mode format. DB2 format is 4 packed decimal bytes with the year in the first two, the month in the next one, and the day in the next one. For example, the value 19900101 would be displayed if the HEX function was applied to date 01/01/1990.