I want to convert a number from decimal (base 10) to base 18 in Snowflake.
I am able to convert this number in Oracle SQL with the to_base
function:
Decimal number: 8581597126547800
Function used: to_base(8581597126547800,18)
Output of base 18 number is 7798G1GG5HGE4
I am able to convert this number in Excel with the base()
function:
Decimal number: 8581597126547800
Function used: =base(8581597126547800,18)
Output of base 18 number is 7798G1GG5HGE4
What is the function in Snowflake that can provide the same result?
You could write your own function like :
create or replace function to_base(num double, base double)
returns varchar
language javascript
as
$$
return NUM.toString(BASE)
$$;
And then use it directly:
select to_base(8581597126547800, 18);
Output:
7798G1GG5HGE4