Re: Subtracting from a date

From: "Moray McConnachie" <moray(dot)mcconnachie(at)computing-services(dot)oxford(dot)ac(dot)uk>
To: "Andy Lewis" <alewis(at)recruitersonline(dot)com>
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:51:35
Message-ID: 01dc01bfa557$c42d1590$760e01a3@oucs.ox.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

That looks good.
If date_effective is a datetime - should be date_effective::datetime if as
Andrew said date_effective is a date field, I guess.
Also your inequality is the wrong way round for things less than or equal to
3 years old, which is what I thought Andrew wanted.

I think it's a bit faster than the age() construction, too.

----------------------------------------------------------------
Moray(dot)McConnachie(at)computing-services(dot)oxford(dot)ac(dot)uk

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2000-04-13 15:37:45 Re: GROUP BY / HAVING - am I being thick?
Previous Message Andrew C.R. Martin 2000-04-13 14:38:27 GROUP BY / HAVING - am I being thick?