--- Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com> wrote:
> Date: Mon, 28 Apr 2003 12:07:00 -0700 (PDT)
> From: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
> Subject: Re: [GENERAL] Selecting the most recent
> To: Mark Tessier <m_tessier(at)sympatico(dot)ca>,
> --- 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
> > today's date, what would be the syntax for
> > that out.
> select * from tablename order by abs(current_date -
> datefield) desc limit 1;
Whoops, that "desc" should not be there: that would
get you the opposite result to the one you want ;-)
Sorry for the (my) confusion.
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
pgsql-general by date
|Next:||From: scott.marlowe||Date: 2003-04-28 21:59:50|
|Subject: Re: > 16TB worth of data question|
|Previous:||From: Antti Haapala||Date: 2003-04-28 21:36:14|
|Subject: Re: timestamps and dates |