Re: absolute value fro timestamps

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Claudio Lapidus <clapidus(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: absolute value fro timestamps
Date: 2003-09-03 21:13:45
Message-ID: 200309032113.h83LDjc28519@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Claudio Lapidus wrote:
> Hello
>
> Evidently is possible to have a negative time interval:
>
> clapidus=> select interval '-1';
> interval
> -----------
> -01:00:00
>
> However, there seems to be no provision to get the absolute value in such
> case:
>
> clapidus=> select @ interval '-1';
> ERROR: operator does not exist: @ interval
> HINT: No operator matches the given name and argument type(s). You may need
> to add explicit typecasts.
>
> clapidus=> select abs(interval '-1');
> ERROR: function abs(interval) does not exist
> HINT: No function matches the given name and argument types. You may need
> to add explicit typecasts.
>
> What did I miss this time?

Why would you want an abolute value of a negative interval?

This works:

test=> select -(interval '-1');
?column?
----------
01:00:00
(1 row)

so I suppose you could create a function or CASE statement to get the
absolute value.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Josué Maldonado 2003-09-03 21:18:34 Re: TCL trigger doesn't work after deleting a column
Previous Message darren 2003-09-03 21:07:48 Re: TCL trigger doesn't work after deleting a column