"Andrus" <[EMAIL PROTECTED]> writes:
>>> Why numeric(2) is not casted to integer automatically ?
>>
>> Because it would lose data, eg '4.4' being rounded to 4.
> I tought that numeric(2) can store only integer data, without decimal
> points.
Oh, I see your confusion: you're supposing that we mig
Why numeric(2) is not casted to integer automatically ?
Because it would lose data, eg '4.4' being rounded to 4.
create temp table test ( test numeric(2));
insert into test values (0.5);
select * from test
returns
1
I'm really confused now.
I tought that numeric(2) can store only integer
"Andrus" <[EMAIL PROTECTED]> writes:
> Why numeric(2) is not casted to integer automatically ?
Because it would lose data, eg '4.4' being rounded to 4.
regards, tom lane
---(end of broadcast)---
TIP 6: explain analyze is you
Alban,
Why would you want to call the function with a numeric? What does 1.2
months mean to you? You're probably only interested in the integer part
of the numeric.
create table test ( m numeric(2) );
select gomonth( current_date, m ) from test;
ERROR: function gomonth(date, numeric) does not
Andrus wrote:
> Thank all very much for great suggestions.
>
> I created function
>
> CREATE OR REPLACE FUNCTION PUBLIC.GOMONTH(DATE, INTEGER, OUT DATE)
> IMMUTABLE
> AS
> $_$
> SELECT ($1 + ($2 * '1 MONTH'::INTERVAL))::DATE;
> $_$ LANGUAGE SQL;
>
> I got errors:
>
> function gomonth(date, nume
Thank all very much for great suggestions.
I created function
CREATE OR REPLACE FUNCTION PUBLIC.GOMONTH(DATE, INTEGER, OUT DATE) IMMUTABLE
AS
$_$
SELECT ($1 + ($2 * '1 MONTH'::INTERVAL))::DATE;
$_$ LANGUAGE SQL;
I got errors:
function gomonth(date, numeric) does not exist
and
function gomont
Andrus wrote:
> I need to create function GOMONTH which returns date by given number of
> month before or forward using sql or pgsql in 8.1+
> For example,
> GOMONTH( DATE '20070513', 1 ) should return date '20070613'
> GOMONTH( DATE '20070513', -2 ) should return date '20070313'
>
> I tried
>
On Sun, 13 May 2007, Andrus wrote:
I need to create function GOMONTH which returns date by given number of
month before or forward using sql or pgsql in 8.1+ For example, GOMONTH(
DATE '20070513', 1 ) should return date '20070613' GOMONTH( DATE
'20070513', -2 ) should return date '20070313'
An
On Sun, May 13, 2007 at 02:26:09PM -0700, Rodrigo De León wrote:
> CREATE OR REPLACE FUNCTION
> PUBLIC.GOMONTH(DATE, INTEGER, OUT DATE) IMMUTABLE AS
> $_$
> SELECT ($1 + ($2 || 'MONTHS')::INTERVAL)::DATE;
> $_$ LANGUAGE SQL
It would probably be better to use:
SELECT ($1 + ($2 * '1 MONTH'::INTERVA
Andrus ha escrito:
> I need to create function GOMONTH which returns date by given number of
> month before or forward using sql or pgsql in 8.1+
> For example,
> GOMONTH( DATE '20070513', 1 ) should return date '20070613'
> GOMONTH( DATE '20070513', -2 ) should return date '20070313'
>
> I tried
10 matches
Mail list logo