Re: Interval ordering - Mailing list pgsql-general

From Adam Rich
Subject Re: Interval ordering
Date
Msg-id 006a01ccdee7$591aec10$0b50c430$@sbcglobal.net
Whole thread Raw
In response to Re: Interval ordering  (Ondrej Ivanič <ondrej.ivanic@gmail.com>)
List pgsql-general
>> try this:
>> select mytime from mytable order by abs(extract(epoch from
>> (usertime-mytime))) asc limit 5;

>> SELECT ts_fld2,abs(extract(epoch from '2011-03-25
>> 14:15:25-07'::timestamptz)-extract(epoch from ts_fld2)) from timestamp_test order
>> by abs(extract(epoch from '2011-03-25 14:15:25-07'::timestamptz)-extract(epoch
>> from ts_fld2)) limit 5;

Thanks to Ondrej and Adrian, who both provided working solutions using extract/epoch.





pgsql-general by date:

Previous
From: Ondrej Ivanič
Date:
Subject: Re: Interval ordering
Next
From: Tom Lane
Date:
Subject: Re: Question about (probably wrong) index scan cost for conditional indexes