Re: Selecting the most recent date

From: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
To: Mark Tessier <m_tessier(at)sympatico(dot)ca>, pgsql-general(at)postgresql(dot)org
Subject: Re: Selecting the most recent date
Date: 2003-04-28 19:07:00
Message-ID: 20030428190700.50580.qmail@web20809.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

--- Mark Tessier <m_tessier(at)sympatico(dot)ca> wrote:
> Hi,
>
> My question is hopefully a simple one: If I have
> several rows, each containing a date field, and I
> want to select the row that has the date closest to
> today's date, what would be the syntax for carrying
> that out.
>
select * from tablename order by abs(current_date -
datefield) desc limit 1;

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sergio Pili 2003-04-28 19:07:32 Error: No one parent tuple was found
Previous Message Jay O'Connor 2003-04-28 18:59:29 Re: Selecting the most recent date