Re: How to implement GOMONTH function

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: How to implement GOMONTH function
Дата
Msg-id 46514FF0.2070700@magproductions.nl
обсуждение исходный текст
Ответ на Re: How to implement GOMONTH function  ("Andrus" <kobruleht2@hot.ee>)
Ответы Re: How to implement GOMONTH function  ("Andrus" <kobruleht2@hot.ee>)
Список pgsql-general
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, numeric) does not exist

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.

> function gomonth(date, bigint ) does not exist

Do you really expect to calculate dates over 2 billion months in the
future or the past?

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.

--
Alban Hertroys
alban@magproductions.nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
   7500 AK Enschede

// Integrate Your World //

В списке pgsql-general по дате отправления:

Предыдущее
От: Rodrigo De León
Дата:
Сообщение: Re: doverlaps() returns null
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Large Database Restore