Contents
make_interval()
A function creating an interval from individual values
make_interval()
is a system function for assembling a interval
value from years, months, weeks, days, hours, minutes and seconds values.
make_interval()
was added in PostgreSQL 9.4.
Usage
make_interval ( [years
int
[,months
int
[,weeks
int
[,days
int
[,hours
int
[,mins
int
[,secs
double precision
]]]]]]] )
→ interval
Each parameter is optional and defaults to 0
if not supplied.
Change history
- PostgreSQL 9.4
- added (commit 84df54b2)
Examples
Basic usage examples for make_interval()
:
postgres=# SELECT make_interval(hours => 1); make_interval --------------- 01:00:00 (1 row) postgres=# SELECT make_interval(years => 2, days => 5, hours => 20, secs => 30.51); make_interval ---------------------------- 2 years 5 days 20:00:30.51 (1 row) postgres=# SELECT make_interval(5,4,3,2,1); make_interval --------------------------------- 5 years 4 mons 23 days 01:00:00 (1 row)
References
- PostgreSQL documentation: Date/Time Functions