PostgreSQL RADIANS() Function
Summary: in this tutorial, you will learn how to use the PostgreSQL RADIANS()
function to convert degrees to radians.
Introduction to the PostgreSQL RADIANS() function
The RADIANS()
function converts degrees to radians.
Here’s the basic syntax of the RADIANS()
function:
In this syntax, the degrees_value
is a value in degrees that you want to convert to radians. The function returns the degrees_value
converted to radians.
If the degrees_value
is NULL
, the function returns NULL
.
PostgreSQL RADIANS() function examples
Let’s explore some examples of using the RADIANS()
function.
1) Basic RADIANS() function example
The following example uses the RADIANS()
function to convert 180 degrees to its equivalent in radians, resulting in PI
value:
Output:
2) Using the RADIANS() function with table data
We’ll show you how to use the RADIANS
with data in a table.
First, create a new table called angles
to store angle data in radians:
Second, insert some rows into the angles
table:
Output:
Third, use the RADIANS()
function to convert the values in the angle_degrees
column to radians:
Output:
Summary
- Use the PostgreSQL
RADIANS()
function to convert degrees to radians.