How the to_number() Function Works in PostgreSQL

In PostgreSQL, you can use the to_number() function to convert a string to a numeric value.

More specifically, it converts the string representation of a number to a numeric value.

For example, if you have $1,234.50 as a string, you can use to_number() to convert that to an actual number that uses the numeric data type.

Continue reading

2 Ways to Convert a Number to Octal in MySQL

If you need to convert a number from decimal to octal (base 8), two functions come to mind if you’re using MySQL. One function is specifically for doing octal conversions, the other is for doing conversions between different bases. These are as follows:

OCT()
This function is used specifically for converting from decimal to octal.
CONV()
This function has a more general purpose. It allows you to specify the base of the original number and the result. In other words, you can convert from any base, to any base (as long as each base is between 2 and 36).

More about these two functions below.

Continue reading