On 2009-11-07, Joshua Berry wrote:
> On Mon, Nov 2, 2009 at 8:35 AM, Jasen Betts wrote:
>|
>| for this case: convert to seconds and then do abs.
>|
>| select * from enviados e, recibidos r where abs(extract ( epoch from
>| (e.fecha - r.fecha) )) < 1
>
> Cheers for that. The query cost is pretty
Joshua Berry wrote:
> On Mon, Nov 2, 2009 at 8:35 AM, Jasen Betts wrote:
> |
> | for this case: convert to seconds and then do abs.
> |
> | ?select * from enviados e, recibidos r where abs(extract ( epoch from
> | ?(e.fecha - r.fecha) )) < 1
>
> Cheers for that. The query cost is pretty heavy, bu
Jasen Betts wrote:
> On 2009-11-01, Lew wrote:
> > I'm writing this at about 8:35 p.m. New York time on October 31, 2009.
> > From
> > now, adding interval '1 day -25 hours' yields right now, New York time.
>
> This year halloween is the longest night. Interesting.
Not the first time this h
On Mon, Nov 02, 2009 at 10:52:40AM +, Jasen Betts wrote:
> what's the absolute value of '1month -30 days'::interval
>
> if I add it to the first of march it goes forwards if I add it to the
In march a month has 31 days.
> first of february if goes backwards. if I add it to the first of april
On Mon, Nov 02, 2009 at 10:52:40AM +, Jasen Betts wrote:
> what's the absolute value of '1month -30 days'::interval
Curious what a use case for taking the absolute value
of such mixed intervals might be.
I could imagine such intervals being used for stuff like
"XXX is due in Y months but need
On Mon, Nov 02, 2009 at 10:52:40AM +, Jasen Betts wrote:
> what's the absolute value of '1month -30 days'::interval
>
> if I add it to the first of march it goes forwards if I add it to the
> first of february if goes backwards. if I add it to the first of april
> it goes nowhere.
>
> select
On Mon, Nov 02, 2009 at 11:22:00AM +, Jasen Betts wrote:
> On 2009-10-27, Sam Mason wrote:
> > On Tue, Oct 27, 2009 at 03:25:02PM +, Sam Mason wrote:
> >> If the absolute value of an interval was defined to strip out all the
> >> negation signs you'd get the "wrong" answers out.
> >
> > Oo
On 2009-11-01, Lew wrote:
> Tom Lane wrote:
>> Sam Mason writes:
>>> On Tue, Oct 27, 2009 at 11:27:17AM -0300, Joshua Berry wrote:
I couldn't find the operator '@' for intervals
>>
>>> A simple SQL implementation would look like:
>>
>>> CREATE FUNCTION absinterval(interval) RETURNS inte
On 2009-10-27, Joshua Berry wrote:
> I couldn't find the operator '@' for intervals and found this thread
> from over six years ago:
> http://archives.postgresql.org/pgsql-general/2003-09/msg00292.php
>
>| "Claudio Lapidus" writes:
>| > Bruce Momjian wrote:
>| >> Why would you want an abolute val
On 2009-10-27, Sam Mason wrote:
> On Tue, Oct 27, 2009 at 03:25:02PM +, Sam Mason wrote:
>> If the absolute value of an interval was defined to strip out all the
>> negation signs you'd get the "wrong" answers out.
>
> Oops, forgot another reason! For maths to work (n) and (-(-n)) should
> ev
On 2009-10-27, Sam Mason wrote:
> On Tue, Oct 27, 2009 at 10:55:31AM -0400, Tom Lane wrote:
>> Sam Mason writes:
>> > On Tue, Oct 27, 2009 at 11:27:17AM -0300, Joshua Berry wrote:
>> >> I couldn't find the operator '@' for intervals
>>
>> > A simple SQL implementation would look like:
>>
>> >
On 2009-10-27, Joshua Berry wrote:
> I couldn't find the operator '@' for intervals and found this thread
> from over six years ago:
> http://archives.postgresql.org/pgsql-general/2003-09/msg00292.php
>
>| "Claudio Lapidus" writes:
>| > Bruce Momjian wrote:
>| >> Why would you want an abolute val
Jeff Davis wrote:
On Thu, 2009-10-29 at 16:39 -0700, Scott Bailey wrote:
But there is some ambiguity around the length of a month. So INTERVAL '1
month - 30 days' = INTERVAL '0 days' = INTERVAL '-1 month +30 days'.
But when added to a date, it makes no change for months with 30 days,
adds 1 d
Tom Lane wrote:
Sam Mason writes:
On Tue, Oct 27, 2009 at 11:27:17AM -0300, Joshua Berry wrote:
I couldn't find the operator '@' for intervals
A simple SQL implementation would look like:
CREATE FUNCTION absinterval(interval) RETURNS interval
IMMUTABLE LANGUAGE sql AS 'SELECT great
On Fri, Oct 30, 2009 at 01:09:30PM -0700, Scott Bailey wrote:
> Sam Mason wrote:
> >My personal feeling is that when you provide any ordering operator and
> >negation you can easily provide an absolute value operator. We've
> >already (somewhat arbitrarily) decided that one of '1month -30days' and
On 30 Oct 2009, at 21:09, Scott Bailey wrote:
My personal feeling is that when you provide any ordering operator
and
negation you can easily provide an absolute value operator. We've
already (somewhat arbitrarily) decided that one of '1month -30days'
and
'-1month 30days) is "greater" than
My personal feeling is that when you provide any ordering operator and
negation you can easily provide an absolute value operator. We've
already (somewhat arbitrarily) decided that one of '1month -30days' and
'-1month 30days) is "greater" than the other, so why not provide an
operator that retu
On Fri, Oct 30, 2009 at 11:39:26AM -0300, Alvaro Herrera wrote:
> Sam Mason wrote:
> > + Datum
> > + interval_abs(PG_FUNCTION_ARGS)
> > + {
> > + Interval *interval1 = PG_GETARG_INTERVAL_P(0);
> > + Interval *interval2 = PG_GETARG_INTERVAL_P(1);
>
> Surely it must receive a single argument
Sam Mason wrote:
> + Datum
> + interval_abs(PG_FUNCTION_ARGS)
> + {
> + Interval *interval1 = PG_GETARG_INTERVAL_P(0);
> + Interval *interval2 = PG_GETARG_INTERVAL_P(1);
Surely it must receive a single argument?
--
Alvaro Herrerahttp://www.CommandPro
On Fri, Oct 30, 2009 at 02:14:31PM +0200, Marko Kreen wrote:
> Slightly makes sense, but only slightly. We deterministically know,
> that we dont have certain timestamp, thus we need to use some default
> values. We already have situation that does that:
>
> extract(epoch from interval)
You'r
On 10/30/09, Sam Mason wrote:
> On Fri, Oct 30, 2009 at 01:45:24PM +0200, Marko Kreen wrote:
> > On 10/30/09, Tom Lane wrote:
>
> > > That was the point of my '1 day -25 hours' example. Whether you
> > > consider that positive or negative seems mighty arbitrary.
> >
> > If I can add it to a
On Fri, Oct 30, 2009 at 01:45:24PM +0200, Marko Kreen wrote:
> On 10/30/09, Tom Lane wrote:
> > That was the point of my '1 day -25 hours' example. Whether you
> > consider that positive or negative seems mighty arbitrary.
>
> If I can add it to a timestamp and get a deterministic result,
> the
On 10/30/09, Tom Lane wrote:
> Jeff Davis writes:
> > Yes, that is a strange case. When you can't tell if an interval is
> > positive or negative, how do you define the absolute value?
>
> That was the point of my '1 day -25 hours' example. Whether you
> consider that positive or negative see
On Fri, Oct 30, 2009 at 12:55:51AM -0400, Tom Lane wrote:
> Jeff Davis writes:
> > Yes, that is a strange case. When you can't tell if an interval is
> > positive or negative, how do you define the absolute value?
>
> That was the point of my '1 day -25 hours' example. Whether you
> consider tha
Jeff Davis writes:
> Yes, that is a strange case. When you can't tell if an interval is
> positive or negative, how do you define the absolute value?
That was the point of my '1 day -25 hours' example. Whether you
consider that positive or negative seems mighty arbitrary.
On Thu, 2009-10-29 at 16:39 -0700, Scott Bailey wrote:
> But there is some ambiguity around the length of a month. So INTERVAL '1
> month - 30 days' = INTERVAL '0 days' = INTERVAL '-1 month +30 days'.
> But when added to a date, it makes no change for months with 30 days,
> adds 1 day for month
I think this came up again recently and somebody pointed out that the
correct definition isn't as obvious as all that. The components of
an interval can have different signs, so should abs('-1 day 1 hour') be
'1 day -1 hour' or '1 day 1 hour'? Or what about corner cases like
'1 day -25 hours'?
Joshua Berry wrote:
I couldn't find the operator '@' for intervals and found this thread
from over six years ago:
http://archives.postgresql.org/pgsql-general/2003-09/msg00292.php
| "Claudio Lapidus" writes:
| > Bruce Momjian wrote:
| >> Why would you want an abolute value of a negative interva
On Tue, Oct 27, 2009 at 03:25:02PM +, Sam Mason wrote:
> If the absolute value of an interval was defined to strip out all the
> negation signs you'd get the "wrong" answers out.
Oops, forgot another reason! For maths to work (n) and (-(-n)) should
evaluate to the same value. Inverting all t
On Tue, Oct 27, 2009 at 10:55:31AM -0400, Tom Lane wrote:
> Sam Mason writes:
> > On Tue, Oct 27, 2009 at 11:27:17AM -0300, Joshua Berry wrote:
> >> I couldn't find the operator '@' for intervals
>
> > A simple SQL implementation would look like:
>
> > CREATE FUNCTION absinterval(interval) RE
Sam Mason writes:
> On Tue, Oct 27, 2009 at 11:27:17AM -0300, Joshua Berry wrote:
>> I couldn't find the operator '@' for intervals
> A simple SQL implementation would look like:
> CREATE FUNCTION absinterval(interval) RETURNS interval
> IMMUTABLE LANGUAGE sql AS 'SELECT greatest($1,-$1)'
On Tue, Oct 27, 2009 at 11:27:17AM -0300, Joshua Berry wrote:
> I couldn't find the operator '@' for intervals
A simple SQL implementation would look like:
CREATE FUNCTION absinterval(interval) RETURNS interval
IMMUTABLE LANGUAGE sql AS 'SELECT greatest($1,-$1)';
CREATE OPERATOR @ ( PROC
I couldn't find the operator '@' for intervals and found this thread
from over six years ago:
http://archives.postgresql.org/pgsql-general/2003-09/msg00292.php
| "Claudio Lapidus" writes:
| > Bruce Momjian wrote:
| >> Why would you want an abolute value of a negative interval?
|
| > Because I'm t
33 matches
Mail list logo