Search Postgresql Archives

Re: interval integer comparison

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 02, 2005 at 01:54:12 +0200,
  Havasvölgyi Ottó <h.otto@xxxxxxxxxxx> 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.

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux