Subject | Re: [firebird-support] adding one year to date |
---|---|
Author | Dimitry Sibiryakov |
Post date | 2004-04-29T06:19:02Z |
On 28 Apr 2004 at 15:17, Raigo wrote:
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.
>How to add exactly one year-1 day to date in Firebird procedure orIn a procedure you can use something like this:
>query? I have to calculate a year period from certain date, for
>example: 01.05.2002 -> 30.04.2003.
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.