Re: date manipulation
Posted in 1996
INTERVAL(value) DAY TO DAY is the way to represent interval literal values!
It is not a function; it is a constant.
CREATE PROCEDURE add_n_days(dt DATETIME YEAR TO SECOND, n1 INTEGER)
RETURNING DATETIME YEAR TO SECOND; DEFINE n2 INTERVAL DAY(9) TO DAY;
DEFINE s CHAR(10);
LET s = n1;
LET n2 = s;
RETURN dt + n2;
END PROCEDURE;
The only reason for making this a procedure is that the call to it converts
the type of the argument automatically, whereas if you tried to write it
inline you'd run into problems. Having to go through a character variable
is objectionable (I object to it), but it works.
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
>From: Sanjay Rao <rao00008@mc.duke.edu>
>Date: Mon, 18 Mar 1996 09:05:19 +0000
>X-Informix-List-Id: <news.22225>
>
>I am trying to write a statement that gives me the date that is
>y days from the current date and time.
>For example, the following statement works in a stored procedure:
>
>define x datetime year to second;
>let x = current year to second - interval(1) day to day;
>
>In the above case I specified "1" day as a parameter to the interval function.
>
>Now for my specific scenario, I would like to use a variable as th parameter
>to the interval function. I get a syntax error.
>
>Does anyone have ideas on how I can accomplish it within the stored procedure?