Subject Re: [ib-support] Re: [IBO] Date Question
Author Jason Wharton
He needs to use a WHEN clause to catch the invalid date error, subtract the
day by one and try it again.

Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com


----- Original Message -----
From: "Nando Dessena" <nandod@...>
To: <ib-support@yahoogroups.com>
Sent: Friday, August 10, 2001 12:52 AM
Subject: Re: [ib-support] Re: [IBO] Date Question


> Hans,
>
> > I found a solution, maybe not the best, but it seems to work :)
> >
> > PROCEDURE THIS_DAY_NEXT_YEAR (CURDATE DATE)
> > RETURNS (NEXTDATE DATE)
> > AS
> > DECLARE VARIABLE YY INTEGER;
> > DECLARE VARIABLE MM INTEGER;
> > DECLARE VARIABLE DD INTEGER;
> > BEGIN
> > YY = Extract(Year from CURDATE);
> > MM = Extract(Month from CURDATE);
> > DD = Extract(Day from CURDATE);
> >
> > NEXTDATE = Cast(mm as char(2))
> > || '/' || Cast(dd as char(2))
> > || '/' || Cast(yy+1 as char(4));
> >
> > SUSPEND;
> > END
>
> it won't work if curdate is 02/29/2004. You should account for leap
> years.
> Ciao
> --
> ____
> _/\/ando