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

How to_timestamp() Works in PostgreSQL

According to the PostgreSQL documentation, there are two functions called to_timestamp():

  • One converts the Unix epoch to a timestamp. The Unix epoch is the number of seconds since 1970-01-01 00:00:00+00.
  • The other converts a string to a timestamp.

More specifically, each function converts the value to a timestamp with time zone value.

Although the Postgres documentation presents them as two separate to_timestamp() functions, I present them as if they’re one function that accepts either one argument, or two.

Continue reading