Re: Fwd: Re: Selecting the most recent date - Mailing list pgsql-general

From Dennis Gearon
Subject Re: Fwd: Re: Selecting the most recent date
Date
Msg-id 3EADB264.6020001@cvc.net
Whole thread Raw
In response to Fwd: Re: Selecting the most recent date  (Jeff Eckermann <jeff_eckermann@yahoo.com>)
Responses Re: Fwd: Re: Selecting the most recent date  (Jeff Eckermann <jeff_eckermann@yahoo.com>)
List pgsql-general
actually, that might be what he wants, all the datefields JUST past, and all the date fields JUST ahead

Jeff Eckermann wrote:
> --- Jeff Eckermann <jeff_eckermann@yahoo.com> wrote:
>
>>Date: Mon, 28 Apr 2003 12:07:00 -0700 (PDT)
>>From: Jeff Eckermann <jeff_eckermann@yahoo.com>
>>Subject: Re: [GENERAL] Selecting the most recent
>>date
>>To: Mark Tessier <m_tessier@sympatico.ca>,
>>    pgsql-general@postgresql.org
>>
>>--- Mark Tessier <m_tessier@sympatico.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;
>>
>
> 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.
> http://search.yahoo.com
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>


pgsql-general by date:

Previous
From: Dennis Gearon
Date:
Subject: Re: encrypt/decrypt problem
Next
From: Dennis Gearon
Date:
Subject: Re: Setting a field to default if blank value