Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 23rd, 2005, 12:29 AM
Brian C. Doyle
Guest
 
Posts: n/a
Default Date Comparison Help


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

  #2  
Old November 23rd, 2005, 12:29 AM
Mike Nolan
Guest
 
Posts: n/a
Default Re: Date Comparison Help

> I need a query to get data that is 6 months older than "today" or when that[color=blue]
> query is run.[/color]

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

  #3  
Old November 23rd, 2005, 12:30 AM
Jim Seymour
Guest
 
Posts: n/a
Default Re: Date Comparison Help

"Brian C. Doyle" <bdoyle@umpa-us.com> wrote:[color=blue]
>
>
> 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?[/color]

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

--
Jim Seymour | Spammers sue anti-spammers:
jseymour@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 majordomo@postgresql.org)

  #4  
Old November 23rd, 2005, 12:30 AM
Brian C. Doyle
Guest
 
Posts: n/a
Default Re: Date Comparison Help

Perfect and thank you so much for the swift response;

At 04:23 PM 4/8/2004, Mike Nolan wrote:[color=blue][color=green]
> > I need a query to get data that is 6 months older than "today" or when[/color]
> that[color=green]
> > query is run.[/color]
>
>WHERE table.date < current_date-interval'6 months'
>--
>Mike Nolan[/color]



----------

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

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles