...

/

Time Intervals

Time Intervals

Learn about time interval styles and implement a calendar using PostgreSQL.

The interval data type

PostgreSQL implements an interval data type along with the time, date, and timestamptz data types. An interval describes a duration, such as a month, two weeks, or even a millisecond:

Press + to interact
set intervalstyle to postgres;
select interval '1 month',
interval '2 weeks',
2 * interval '1 week',
78389 * interval '1 ms';

The default PostgreSQL output looks like this:

 interval │ interval │ ?column? │   ?column?  
...