An interval value represents the duration between two points in time.
Syntax
[ @ ] quantity unit [ quantity unit... ] [ AGO ]
Semantics
|
(at sign) is optional and ignored |
|
quantity |
is an integer numeric constant |
|
unit
|
is one of the following units or abbreviations or plurals of the following units: |
|
SECOND MINUTE HOUR DAY WEEK |
MONTH YEAR DECADE CENTURY MILLENNIUM |
|
AGO |
(optional) specifies a negative interval value (an interval going back in time) |
The amounts of different units are implicitly added up with appropriate sign accounting.
Notes
'1 12:59:10'
is read the same as '1 day 12 hours 59 min 10 sec'
Examples
=> SELECT TIMESTAMP 'Apr 1, 07' - TIMESTAMP 'Mar 1, 07';
?column?
----------
1 mon
(1 row)
=> SELECT TIMESTAMP 'Mar 1, 07' - TIMESTAMP 'Feb 1, 07';
?column?
----------
1 mon
(1 row)
=> SELECT TIMESTAMP 'Feb 1, 07' + INTERVAL '30 days';
?column?
---------------------
2007-03-01 00:00:00
(1 row)