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

From Dennis Gearon
Subject Re: Selecting the most recent date
Date
Msg-id 3EAD7114.50002@cvc.net
Whole thread Raw
In response to Selecting the most recent date  (Mark Tessier <m_tessier@sympatico.ca>)
List pgsql-general
select (rows desired)
from tableselect
where abs( todays_date - col_date) = min( abs( todays_date - col_date));

SORT OF <LOL>, I'm not sure how to find that particular row, but is how you find the minimum difference from todays
date.

Mark Tessier wrote:
> Hi,
>
> My question is hopefully a simple one:  If I have several rows, each containing a date field, and I want to select
therow that has the date closest to today's date, what would be the syntax for carrying that out. 
>


pgsql-general by date:

Previous
From: "Robert Fitzpatrick"
Date:
Subject: Re: Setting a field to default if blank value
Next
From: Dennis Gearon
Date:
Subject: Re: problems restoring 7.2.1 dump to 7.3.2