By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,603 Members | 1,072 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,603 IT Pros & Developers. It's quick & easy.

Date Comparison Help

P: n/a

Hello all,

I am rather confident that this has been answered in the past but searching
for it has been a pain so I am asking for some assistance.

I need a query to get data that is 6 months older than "today" or when that
query is run.

So the where clause is something like

WHERE table.date >= now() - 6 months

I know that will not work so how should I do this?

----------

UMPA
Brian C. Doyle
Director, Internet Services
United Merchant Processing Association
<http://www.umpa-us.com>http://www.umpa-us.com
1-800-555-9665 ext 212

Nov 23 '05 #1
Share this Question
Share on Google+
3 Replies

P: n/a
> I need a query to get data that is 6 months older than "today" or when that
query is run.


WHERE table.date < current_date-interval'6 months'
--
Mike Nolan

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #2

P: n/a
"Brian C. Doyle" <bd****@umpa-us.com> wrote:


Hello all,

I am rather confident that this has been answered in the past but searching
for it has been a pain so I am asking for some assistance.

I need a query to get data that is 6 months older than "today" or when that
query is run.

So the where clause is something like

WHERE table.date >= now() - 6 months

I know that will not work so how should I do this?


WHERE age(table.date) > '6 months'

--
Jim Seymour | Spammers sue anti-spammers:
js******@LinxNet.com | http://www.LinxNet.com/misc/spam/slapp.php
http://jimsun.LinxNet.com | Please donate to the SpamCon Legal Fund:
| http://www.spamcon.org/legalfund/

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #3

P: n/a
Perfect and thank you so much for the swift response;

At 04:23 PM 4/8/2004, Mike Nolan wrote:
I need a query to get data that is 6 months older than "today" or when

that
query is run.


WHERE table.date < current_date-interval'6 months'
--
Mike Nolan


----------

UMPA
Brian C. Doyle
Director, Internet Services
United Merchant Processing Association
<http://www.umpa-us.com>http://www.umpa-us.com
1-800-555-9665 ext 212

Nov 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.