Subject Re: Add Year function
Author Svein Erling Tysvær
Hi!

Adding 100 years is a pretty simple thing that can easily be done
without any UDF. It is made slightly more complicated by the fact that
the year 2000 was a leap year whereas 1900 wasn't. Note that I've
never actually tried using a CASE statement within an UPDATE, but you
get the idea:

> CREATE PROCEDURE ADDYEAR_PROCEDURE
> AS
> BEGIN
> UPDATE OldDateTable
> SET Transaction_Date = case
> when Transaction_Date < '1.3.1900' then
> Transaction_Date + 36524
> else
> Transaction_Date + 36525
> end
> WHERE Transaction_Date < '1.1.1910';
>// SUSPEND; SUSPEND is for selectable procedures only, remove it.
>END

HTH,
Set

--- In firebird-support@yahoogroups.com, "alanpltse" wrote:
> Hi Adam,
>
> Yes, I found the script:
> declare external function addYear
> timestamp, int
> returns timestamp
> entry_point 'addYear' module_name 'fbudf'
>
> But I got the same error AddYear is not defined when I compile my
> stored procedure.
>
> CREATE PROCEDURE ADDYEAR_PROCEDURE
> AS
> BEGIN
> UPDATE OldDateTable
> SET Transaction_Date = ADDYEAR(Transaction_Date, 100)
> WHERE Transaction_Date < 1910;
> SUSPEND;
> END