Re: Fwd: Re: Selecting the most recent date

From: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
To: gearond(at)cvc(dot)net
Cc: Mark Tessier <m_tessier(at)sympatico(dot)ca>, pgsql-general(at)postgresql(dot)org
Subject: Re: Fwd: Re: Selecting the most recent date
Date: 2003-04-29 13:59:51
Message-ID: 20030429135951.24408.qmail@web20801.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

--- Dennis Gearon <gearond(at)cvc(dot)net> wrote:
> actually, that might be what he wants, all the
> datefields JUST past, and all the date fields JUST
> ahead

The specification was ambiguous: I took "closest to"
to mean "shortest distance away", i.e. in any
direction.

>
> Jeff Eckermann wrote:
> > --- 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
> >>date
> >>To: Mark Tessier <m_tessier(at)sympatico(dot)ca>,
> >> pgsql-general(at)postgresql(dot)org
> >>
> >>--- 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;
> >>
> >
> > 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
> >
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please
> send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org
> so that your
> message can get through to the mailing list cleanly

__________________________________
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 Nigel J. Andrews 2003-04-29 14:01:32 Re: Error: No one parent tuple was found
Previous Message Tom Lane 2003-04-29 13:56:42 Re: timestamps and dates