Subject | Re: [ib-support] date question |
---|---|
Author | hans@hoogstraat.ca |
Post date | 2001-08-10T16:30:36Z |
Hello,
Thank You all for the help.
Since I want This Day Next Year, the leap year issue is simple. There
never will be a leap year as This Day Next Year and the best I can
do is the 28th of Feb.
Why do I need such a silly thing. I'm trying to convert an smart travel
agency quotation program from Pervasive SQL to IB6 SQL, which holds a
confirmed price for a tour from say Jan 5,2001 to Jan 10,2001. Now we
want to extimate a price for a quote in year 2002 assuming a fixed
percentage of increase per year, till the official price of the tour has
been confirmed.
Best Regards,
Hans
================= Final Answer ===============
PROCEDURE THISDAYNEXTYEAR( CURDATE DATE )
RETURNS ( NEXTDATE DATE )
AS
DECLARE VARIABLE YY INTEGER;
DECLARE VARIABLE MM INTEGER;
DECLARE VARIABLE DD INTEGER;
BEGIN
IF (CURDATE IS NULL) THEN
CURDATE = '01/01/1979';
YY = Extract(Year from CURDATE);
MM = Extract(Month from CURDATE);
DD = Extract(Day from CURDATE);
IF (MM = 2 AND DD > 28) THEN
NEXTDATE = CAST( 28 || '.' || MM || '.' || (YY+1) as DATE);
ELSE
NEXTDATE = CAST( DD || '.' || MM || '.' || (YY+1) as DATE);
SUSPEND;
END
Thank You all for the help.
Since I want This Day Next Year, the leap year issue is simple. There
never will be a leap year as This Day Next Year and the best I can
do is the 28th of Feb.
Why do I need such a silly thing. I'm trying to convert an smart travel
agency quotation program from Pervasive SQL to IB6 SQL, which holds a
confirmed price for a tour from say Jan 5,2001 to Jan 10,2001. Now we
want to extimate a price for a quote in year 2002 assuming a fixed
percentage of increase per year, till the official price of the tour has
been confirmed.
Best Regards,
Hans
================= Final Answer ===============
PROCEDURE THISDAYNEXTYEAR( CURDATE DATE )
RETURNS ( NEXTDATE DATE )
AS
DECLARE VARIABLE YY INTEGER;
DECLARE VARIABLE MM INTEGER;
DECLARE VARIABLE DD INTEGER;
BEGIN
IF (CURDATE IS NULL) THEN
CURDATE = '01/01/1979';
YY = Extract(Year from CURDATE);
MM = Extract(Month from CURDATE);
DD = Extract(Day from CURDATE);
IF (MM = 2 AND DD > 28) THEN
NEXTDATE = CAST( 28 || '.' || MM || '.' || (YY+1) as DATE);
ELSE
NEXTDATE = CAST( DD || '.' || MM || '.' || (YY+1) as DATE);
SUSPEND;
END