Contents
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
- PostgreSQL 8.2
- added (commit d69b1632)
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)
References
- PostgreSQL documentation: Date/Time Functions