w3resource

PostgreSQL JUSTIFY_INTERVAL() function

JUSTIFY_INTERVAL() function

The PostgreSQL JUSTIFY_INTERVAL() function is used to adjust intervals by using justify_days and justify_hours, along with additional sign adjustments..

Uses of JUSTIFY_INTERVAL() Function
  • Adjusts intervals to account for 30-day periods as months and 24-hour periods as days.

  • Ensures consistent and simplified representation of intervals.

  • Handles sign adjustments to maintain logical interval representation.

Syntax:

justify_interval(interval)

Return Type: interval.

PostgreSQL Version: 9.3

Pictorial Presentation of PostgreSQL JUSTIFY_INTERVAL() function

Pictorial presentation of PostgreSQL JUSTIFY_INTERVAL() function

Example: PostgreSQL JUSTIFY_INTERVAL() function

Code:

SELECT justify_interval(interval '1 mon -1 hour');

Sample Output:

justify_interval
------------------
 29 days 23:00:00
(1 row)

Previous: JUSTIFY_HOURS function
Next: LOCALTIMESTAMP function



Follow us on Facebook and Twitter for latest update.