justify_interval()

A function for adjusting days and hours units in an interval

justify_interval() is a system function for adjusting days and hours in an interval into months and days respectively.

justify_interval() was added in PostgreSQL 8.2.

Usage

justify_interval ( interval ) → interval

justify_interval() effectively combines the functionalty of justify_days() and justify_hours().

Change history

Examples

Basic usage example for justify_interval():

postgres=# SELECT justify_interval('43 days 28 hours');
    justify_interval    
------------------------
 1 mon 14 days 04:00:00
(1 row)

Note that as with justify_days(), a month is considered to be 30 days, which can result in potentially misleading output:

postgres=# SELECT justify_interval('364 days 24 hours');
 justify_interval 
------------------
 1 year 5 days
(1 row)

Categories

Date and time, System function

See also

justify_days(), justify_hours()