Skip to content

MAKE_INTERVAL

Make an interval value by adding a series of values that represent the year, months, weeks, days, hours, minutes, and seconds. (You can specify all or some of these values.)

make_interval(years, months, weeks, days, hours, mins, secs)
  • The year, month, day, hour, and minute values are integers. All of these values default to 0.
  • The seconds value is a double precision number that defaults to 0.0.

For example:

premdb=# SELECT MAKE_INTERVAL(1995,1,1,1,1,1,1);
         make_interval           
----------------------------------
 1995 years 1 mon 8 days 01:01:01
(1 row)
premdb=# SELECT MAKE_INTERVAL(1995);
 make_interval 
---------------
 1995 years
(1 row)
premdb=# SELECT matchday, MAKE_INTERVAL(1,1,1,1,1,1,1)+matchday matchday_plus_one 
FROM match WHERE seasonid=3 LIMIT 2;
     matchday       |  matchday_plus_one  
---------------------+---------------------
 1994-12-26 00:00:00 | 1996-02-03 01:01:01
 1994-08-31 00:00:00 | 1995-10-08 01:01:01
(2 rows)

Parent topic:Datetime Functions