Re: Subtracting from a date

From: Andy Lewis <alewis(at)recruitersonline(dot)com>
To: Moray McConnachie <moray(dot)mcconnachie(at)computing-services(dot)oxford(dot)ac(dot)uk>
Cc: Andrew Perrin - Demography <aperrin(at)demog(dot)berkeley(dot)edu>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Subtracting from a date
Date: 2000-04-13 14:06:09
Message-ID: Pine.LNX.4.20.0004130901110.21309-100000@mail.recruitersonline.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

What would be wrong with:

SELECT date_effective FROM your_table WHERE date_effective <= (now() + '3 years ago')

Certainly looks alittle mmore readable.

Andy

On Thu, 13 Apr 2000, Moray McConnachie wrote:

> WHERE age('now',date_effective::datetime)<='3 years'::timespan
>
> I don't know if 'now' in that context is still the authoritative way to
> write now, maybe it should be
>
> WHERE age(now(),date_effective::datetime)<='3 years'::timespan
>
> if date_effective is actually a datetime field, which I understand we are
> moving to in 7.0 (date fields being non-SQL-standard), then you don't need
> the cast, obviously.
> ----------------------------------------------------------------
> Moray(dot)McConnachie(at)computing-services(dot)oxford(dot)ac(dot)uk
>
> ----- Original Message -----
> From: "Andrew Perrin - Demography" <aperrin(at)demog(dot)berkeley(dot)edu>
> To: <pgsql-sql(at)postgresql(dot)org>
> Sent: Wednesday, April 12, 2000 6:46 PM
> Subject: [SQL] Subtracting from a date
>
>
> > I need to find all records with a date field (date_effective) 3 years or
> > less prior to now(). This clearly must be possible, but I'm not figuring
> > it out. Any suggestions?
> >
> > ---------------------------------------------------------------------
> > Andrew J. Perrin - aperrin(at)demog(dot)berkeley(dot)edu - NT/Unix Admin/Support
> > Department of Demography - University of California at Berkeley
> > 2232 Piedmont Avenue #2120 - Berkeley, California, 94720-2120 USA
> > http://demog.berkeley.edu/~aperrin --------------------------SEIU1199
> >
> >
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew C.R. Martin 2000-04-13 14:38:27 GROUP BY / HAVING - am I being thick?
Previous Message Stephan Szabo 2000-04-13 11:18:36 Re: foreign key