Re: [GENERAL] Temporal query question

2004-11-30 Thread Tom Lane
Richard Huxton <[EMAIL PROTECTED]> writes: > SELECT now() - (1 || ' days')::interval; Note that the preferred form is SELECT now() - (n * '1 day'::interval); if n is a numeric variable. When you write SELECT now() - (n || ' days')::interval; you are relying on the following: (

Re: [GENERAL] Temporal query question

2004-11-30 Thread Richard Huxton
Stefano Bonnin wrote: Hi all, I have a "simple" question about the following temporal query with "interval" operator: can I define a query of this type? select myfield,numeric_field from mytable where temporal_attribute < temporal_attribute - interval numeric_field || ' days' obviously this syntax

Re: [GENERAL] Temporal query question

2004-11-30 Thread Martijn van Oosterhout
The usual syntax is something like: select myfield,numeric_field from mytable where temporal_attribute_a < temporal_attribute_b - ( numeric_field * '1 day'::interval); One of the temporal_attributes tends to be 'now' or 'today' but the principle is the same... On Tue, Nov 30, 2004 at 11:30:16

[GENERAL] Temporal query question

2004-11-30 Thread Stefano Bonnin
Hi all,   I have a "simple" question about the following temporal query with "interval" operator:   can I define a query of this type?   select myfield,numeric_field from mytable where temporal_attribute < temporal_attribute - interval numeric_field || ' days'   obviously this syntax is wrong