In PostgreSQL, the justify_interval()
function adjusts an interval using justify_days
 and justify_hours
. It allows you to use additional sign adjustments to adjust the interval.
Category: DBMS
Database Management Systems
How justify_days() Works in PostgreSQL
In PostgreSQL, the justify_days()
function allows you to adjust an interval value, so that 30-day time periods are represented as months.
For example, if you have an interval of say, 30 days, justify_days()
will return it as 1 mon.
How justify_hours() Works in PostgreSQL
In PostgreSQL, the justify_hours()
function allows you to adjust an interval value, so that 24-hour time periods are represented as days.
For example, if you have an interval of say, 24 hours justify_hours()
will return it as 1 day.
Return a List of Timezones Supported by PostgreSQL
When working with PostgreSQL, you may occasionally find yourself in the situation where you need a list of timezones that Postgres recognises.
For example, you could be trying to set the timezone for your current session, or you could be using one of the datetime functions that allow you to manipulate the timezone.
Below are two views and two functions that return a list of timezones.
Continue readingHow IsFinite() Works in PostgreSQL
In PostgreSQL, the isfinite()
function tests for a finite date, timestamp or interval.
This can be useful, because Postgres supports infinite dates/timestamps. For example, you could have a timestamp of infinity or negative infinity, and this function allows you to test for that.
Continue readingHow pg_typeof() Works in PostgreSQL
In PostgreSQL, the pg_typeof()
function allows you to get the data type of any value.
More specifically, it returns the OID of the data type of the value that is passed to it. It returns a regtype
, which is an OID alias type. Therefore it’s the same as an OID for comparison purposes but displays as a type name.
How Div() Works in PostgreSQL
In PostgreSQL, the div()
function returns the integer quotient of its first argument divided by its second argument.
How the Power() Function Works in PostgreSQL
In PostgreSQL, the power()
function returns its first argument raised to the power of its second argument.
How the Scale() Function Works in PostgreSQL
In PostgreSQL, the scale()
function returns the scale of its argument.
The scale is the number of decimal digits in the fractional part.
Continue readingHow the Sign() Function Works in PostgreSQL
In PostgreSQL, the sign()
function is used to indicate the sign of its argument.
It doesn’t simply return the actual sign. Rather, it returns -1 for negative numbers, 0 for zero, and 1 for positive numbers.
Continue reading