Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group