justify_days()

A function converting 30 day intervals into months

justify_days() is a system function for adjusting an interval so 30-day time periods are represented as months.

justify_days() was added in PostgreSQL 8.1.

Usage

justify_days ( interval ) → interval

Change history

Examples

Basic usage example for justify_days():

postgres=# SELECT justify_days('67 days');
 justify_days  
---------------
 2 mons 7 days
(1 row)

As the "month" is defined as a fixed value of 30 days, this function can only provide a very approximate conversion, which results in potentially misleading output:

postgres=# SELECT justify_days('365 days');
 justify_days  
---------------
 1 year 5 days
(1 row)

Categories

Date and time, System function

See also

justify_hours(), justify_interval()