In PostgreSQL, exp()
is a mathematical function that returns the exponential value of its argument.
Author: Ian
Get the Century from a Date in PostgreSQL
In Postgres, you can use the to_char()
function to return the century, based on a given date.
To do this, use CC
as the second argument. This returns the two-digit century based on the date provided.
How to Create Ordinal Numbers in PostgreSQL
In PostgreSQL, you can use the to_char()
function to output numbers in a given format. This includes appending the number with the ordinal indicator.
For example 1, 2, 3 becomes 1st, 2nd, 3rd.
Continue readingHow Pi() Works in PostgreSQL
In PostgreSQL, the pi()
function returns the number π.
π constant is a mathematical constant. It is defined as the ratio of a circle’s circumference to its diameter.
Continue readingHow the Degrees() Function Works in PostgreSQL
In PostgreSQL, the degrees()
function converts from radians to degrees.
The radian is the SI (International System of Units) unit for measuring angles. One radian is just under 57.3 degrees, and a full circle has just over 6.28 radians (2π).
Continue readingHow the Radians() Function Works in PostgreSQL
In PostgreSQL, the radians()
function converts from degrees to radians.
The radian is the SI (International System of Units) unit for measuring angles. One radian is just under 57.3 degrees, and a full circle has just over 6.28 radians (2π).
Continue readingHow Trunc() Works in PostgreSQL
In PostgreSQL, the trunc()
function truncates a number.
More specifically, it truncates the number either toward zero, or to a specific number of decimal places.
Continue readingAdd the Ordinal Indicator to a Date in PostgreSQL
The PostgreSQL to_char()
function provides us with the option of adding the ordinal number suffix to the result.
This means we can add the ordinal indicator when formatting dates.
For example, instead of outputting 10 Feb we could output 10th Feb.
Continue readingInstall Postgres.app on a Mac
The easiest way to install PostgreSQL on a Mac is by installing Postgres.app. Postgres.app is a full-featured PostgreSQL installation packaged as a standard Mac application.
You simply download it and drag it to your Applications folder, just like with any other application.
Continue readingHow Ceiling() Works in PostgreSQL
In PostgreSQL, the ceiling()
function is used for rounding a number up to the nearest integer.
It’s similar to round()
, except that it only rounds up. The round()
function will round up or down as required.
It’s also similar to floor()
, except that floor()
rounds down instead of up.