Operators are similar to functions (see Section
on page
). Table
lists the most common operators.
All data types support the standard comparison operators
<, <=, =, >=, >,
and <>. Not all operator/type combinations
are defined, however. For example, if you try to add two DATE
values, you will get an error, as shown in the first query of Figure .
test=> SELECT CAST('1/1/1992' AS DATE) + CAST('1/1/1993' AS DATE);
ERROR: Unable to identify an operator '+' for types 'date' and 'date'
You will have to retype this query using an explicit cast
test=> SELECT CAST('1/1/1992' AS DATE) + CAST('1 year' AS INTERVAL);
?column?
------------------------
1993-01-01 00:00:00-05
(1 row)
test=> SELECT CAST('1/1/1992' AS TIMESTAMP) + '1 year';
?column?
------------------------
1993-01-01 00:00:00-05
(1 row)