The pgsql-general mailing list is discussed here: The absolute value of intervals about why the built-in abs(interval) function is not provided by PostgreSQL.
In short, there is no consensus on what it should do in some cases when considering the component nature of an interval type.
But anyone can create their own function, realizing their own idea of what it should calculate, for example, based on an expression from LisMorski's answer :
CREATE FUNCTION abs(interval) RETURNS interval AS $$ select case when ($1<interval '0') then -$1 else $1 end; $$ LANGUAGE sql immutable;
Simple SQL functions are usually built-in during query execution, so performance should be comparable to the expression inside the query.
Example:
#= select abs(interval '-2 days +3 minutes'); abs ------------------ 2 days -00:03:00
Daniel Vérité
source share