TO_BASE

All functions > MATH > TO_BASE

Converts a decimal number to a specified base representation.

Syntax

TO_BASE(expr, base)
sql

Arguments

ParameterTypeRequiredDescription
decimal_numberBIGINTYesThe decimal (base 10) number to convert
baseBIGINTYesThe target base (2-36)

Returns

VARCHAR - String representation in the target base

Notes

  • Supports bases from 2 (binary) to 36
  • For bases > 10, uses letters A-Z for digits 10-35
  • Returns uppercase letters for bases > 10
  • Returns NULL if decimal_number is NULL
  • Useful for converting to binary, octal, hexadecimal

Examples

Last update at: 2025/10/13 10:23:46