Re: Interval ordering

From: "Adam Rich" <adam(dot)r(at)sbcglobal(dot)net>
To: "'Adrian Klaver'" <adrian(dot)klaver(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Interval ordering
Date: 2012-01-29 22:39:12
Message-ID: 006901ccded6$d379e350$7a6da9f0$@sbcglobal.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> How about something like:
> test(5432)aklaver=>SELECT ts_fld2,now()-ts_fld2 from timestamp_test order
by
> now()-ts_fld2 limit 5;

Thanks Adrian,
Let me explain the problem better. Say my table has 24 entries, one for
each
hour, midnight through 11 pm. If the user enters "6:30 PM", I want to give
them
the closest times in proximity - both before AND after - to their input...
so in this
case, I'd return 5:00 PM, 6:00 PM, 7:00 PM, 8:00 PM, etc.

I believe your solution only provides the closest times BEFORE and not
AFTER.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2012-01-29 22:40:56 Re: FOSDEM booth volunteer
Previous Message Adrian Klaver 2012-01-29 22:33:09 Re: Interval ordering