1 Answer
- Newest
- Most votes
- Most comments
0
Yes, it is possible to convert hexadecimal numbers to decimal in AWS IoT SQL. Here is one way to do it:
Use the CAST function to convert the hexadecimal string to a BIGINT. This will interpret the hex string as a base 16 number and convert it to a decimal integer.
For example:
SELECT CAST('07e7' AS BIGINT) AS decimal_value
Would output:
decimal_value 2023
The CAST function handles strings of different lengths, so you can convert 1 byte hex values like '08' up to 8 byte values like '13a5'.
Some examples:
SELECT CAST('08' AS BIGINT) AS decimal_value
Would output:
decimal_value
8
SELECT CAST('19' AS BIGINT) AS decimal_value
Would output:
decimal_value 25
SELECT CAST('13a5' AS BIGINT) AS decimal_value
Would output:
decimal_value 5029
answered 6 months ago
Relevant content
- asked 9 months ago
- Accepted Answerasked 4 years ago
- asked a year ago
- asked 2 months ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 5 months ago
Thank you. But error.....
SqlParseException Unknown data type 'BIGINT' BIGINT) AS decimal_value ---------------------^ at 1:22