Re: Subtracting from a date - Mailing list pgsql-sql

From Moray McConnachie
Subject Re: Subtracting from a date
Date
Msg-id 01dc01bfa557$c42d1590$760e01a3@oucs.ox.ac.uk
Whole thread Raw
In response to Re: Subtracting from a date  (Andy Lewis <alewis@recruitersonline.com>)
List 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.McConnachie@computing-services.oxford.ac.uk



pgsql-sql by date:

Previous
From: "Andrew C.R. Martin"
Date:
Subject: GROUP BY / HAVING - am I being thick?
Next
From: Tom Lane
Date:
Subject: Re: GROUP BY / HAVING - am I being thick?