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

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$ (view raw, whole thread or download thread mbox)
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.


In response to

pgsql-sql by date

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

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