Re: How to implement GOMONTH function - Mailing list pgsql-general

From Andrus
Subject Re: How to implement GOMONTH function
Date
Msg-id f2rlv6$1lsl$1@news.hub.org
Whole thread Raw
In response to Re: How to implement GOMONTH function  (Alban Hertroys <alban@magproductions.nl>)
Responses Re: How to implement GOMONTH function
List pgsql-general
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 exist

Do you think it is bad practice to use the table structure above ?
Do you think that I must use integer instead of numeric(2) and change all my
table structures?

Why numeric(2) is not casted to integer automatically ?

>> function gomonth(date, bigint ) does not exist
>
> Do you really expect to calculate dates over 2 billion months in the
> future or the past?

I really do not want. PostgeSQL wants it.

create table test ( t integer  );
select gomonth( current_date, sum(t) ) from test;

ERROR: function gomonth(date, bigint) does not exist

> If you really want to; you can write gomonth versions for numeric and
> bigint month counts with a body that casts the months value to integer
> and calls the gomonth(date, integer) version.

I really want to write only single function version.

Andrus.


pgsql-general by date:

Previous
From: "Pablo Hume"
Date:
Subject: Call a program
Next
From: marcelo Cortez
Date:
Subject: help with query