Difference in DATEs

Assume that x and y are of type DATE:

1. AGE( x, y ) < INTERVAL '...' works.

2. x < y + INTERVAL '...' works.

3. x - y < INTERVAL '...' doesn't work (but then, the minus operator is not
defined in the manual for two DATE values).

Question: Is the meaning of x - y well-defined? That is, is there a
definition that I can count on?

Not an important question, but I'm curious, since I like to write date
differences in a style that makes readability/maintenance easy.

-- Dean


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
postgresql3 [ Di, 21 September 2004 09:38 ] [ ID #453656 ]

Re: Difference in DATEs

"Dean Gibson (DB Administrator)" <postgresql3 [at] ultimeth.com> writes:
> 3. x - y < INTERVAL '...' doesn't work (but then, the minus operator is not
> defined in the manual for two DATE values).

Sure it is: see 10th row in
http://www.postgresql.org/docs/7.4/static/functions-datetime .html#OPERATORS-DATETIME-TABLE

Forget the interval and compare to an integer.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo [at] postgresql.org
tgl [ Di, 21 September 2004 16:01 ] [ ID #453661 ]

Re: Difference in DATEs

Tom Lane wrote on 2004-09-21 07:01:
>Sure it is: see 10th row in
>http://www.postgresql.org/docs/7.4/static/functions-datetim e.html#OPERATORS-DATETIME-TABLE
>
>Forget the interval and compare to an integer.

Thanks; that line is not present in the table in the 7.3.4 docs.

-- Dean


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo [at] postgresql.org
postgresql3 [ Di, 21 September 2004 17:53 ] [ ID #453664 ]
Datenbanken » comp.databases.postgresql.sql » Difference in DATEs

Vorheriges Thema: LIKE operator and string comparison
Nächstes Thema: Help with function