Search⌘ K

Time Intervals

Explore how PostgreSQL handles the interval data type alongside date and time types. Learn to work with durations like months or minutes and understand PostgreSQL's calendar-aware interval computations to manage temporal data precisely.

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:

PostgreSQL
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?  
...