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

From Alban Hertroys
Subject Re: How to implement GOMONTH function
Date
Msg-id 46514FF0.2070700@magproductions.nl
Whole thread Raw
In response to Re: How to implement GOMONTH function  ("Andrus" <kobruleht2@hot.ee>)
Responses Re: How to implement GOMONTH function
List 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 by date:

Previous
From: Rodrigo De León
Date:
Subject: Re: doverlaps() returns null
Next
From: Richard Huxton
Date:
Subject: Re: Large Database Restore