Subject Re: [firebird-support] adding one year to date
Author Dimitry Sibiryakov
On 28 Apr 2004 at 15:17, Raigo wrote:

>How to add exactly one year-1 day to date in Firebird procedure or
>query? I have to calculate a year period from certain date, for
>example: 01.05.2002 -> 30.04.2003.

In a procedure you can use something like this:

ADay = EXTRACT(DAY from TheDate);
AMonth = EXTRACT(MONTH from TheDate);
AYear = EXTRACT(YEAR from TheDate);
NextYearDate = CAST(CAST(ADay as VARCHAR(2))||'.'||
CAST(AMonth as VARCHAR(2))||'.'||
CAST(AYear+1 as VARCHAR(4)) as DATE)-1;

You'll be in troubles with 29.02, but it is a matter of one
additional check.

You can also just use addYear UDF from fbudf library.

SY, Dimitry Sibiryakov.