| From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
|---|---|
| To: | Havasvölgyi Ottó <h(dot)otto(at)freemail(dot)hu> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: interval integer comparison |
| Date: | 2005-06-02 01:53:22 |
| Message-ID: | 20050602015322.GA30920@wolff.to |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Thu, Jun 02, 2005 at 01:54:12 +0200,
Havasvölgyi Ottó <h(dot)otto(at)freemail(dot)hu> wrote:
> Thank you Tom.
>
> It was a bit confusing because my WHERE clause looked something like this:
>
> ... WHERE date_field - current_date < '21 days'::interval;
>
> And then I got records, whose with date_field's year was 2010. :-o
> Now I am using this formula:
>
> ... WHERE date_field < current_date + '21 days'::interval;
If date_field and current_date are realy of type date (and not say
some timestamp varient), then you should use:
... WHERE date_field < current_date + 21
What you used above may have unexpected results near a daylight savings
time change as the data will be promoted to timestamps to do the
comparison.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Eisenhut, Glenn | 2005-06-02 05:22:01 | Determining when a row was inserted |
| Previous Message | Roman F | 2005-06-02 01:28:38 | Deleting orphaned records to establish Ref Integrity |