Hi,
On 30 January 2012 09:19, Adam Rich <adam(dot)r(at)sbcglobal(dot)net> wrote:
> desired time, I want to show them the 5 times from the table that are
> closest to their
>
> input. I expected to do this using abs() like such:
>
> select mytime from mytable order by abs(usertime-mytime) asc limit 5;
>
> However, the difference between times is an interval, and there appears to
> be no
>
> absolute value operator for those. My next thought was to convert the
> interval
try this:
select mytime from mytable order by abs(extract(epoch from
(usertime-mytime))) asc limit 5;
--
Ondrej Ivanic
(ondrej(dot)ivanic(at)gmail(dot)com)