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



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/PostgreSQL/justify_interval-function.php