Subject | Re: How do I subtract an integer form a date inside of a stored procedure |
---|---|
Author | Alexander V.Nevsky |
Post date | 2004-04-30T18:54:18Z |
--- In firebird-support@yahoogroups.com, "M Tuttle \(KS\)"
<miket@s...> wrote:
curiosity, made test database and:
Create procedure Datearithm
Returns (iNumOfDays SMALLINT, dCurrentDate DATE,
iAutoDefaultDays SMALLINT, NextPmtDueDate DATE)
as
begin
dCurrentDate = CURRENT_DATE;
NextPmtDueDate='5/30/2004';
iNumOfDays = ((NextPmtDueDate + iAutoDefaultDays) - dCurrentDate);
Suspend;
end
and
Select * From Datearithm
all worked exactly as in my beloved dialect 1:
INUMOFDAYS DCURRENTDATE IAUTODEFAULTDAYS NEXTPMTDUEDATE
33 30.04.2004 3 30.05.2004
looks like you declared wrong type for one of variables/parameters in
your procedure or on client side, char instead date for example or try
to return time interval into Date. Perhaps smallint is too small to
store iNumOfDays for some NextPmtDueDate. General recommendation -
don't save money buying matches, short types as smallint, float etc
are tribute for times when computer occupied square of swimming-pool
and amount of RAM and disk space was measured in KBytes.
Best regards,
Alexander.
<miket@s...> wrote:
> Greetings,payment
>
> I am trying to subtract today's date (dCurrentDate) from the next
> date (NextPmtDueDate) less so many grace days (iAutoDefaultDays)following
>
> Here is a portion of my stored procedure:
>
> DECLARE VARIABLE iNumOfDays SMALLINT;
> DECLARE VARIABLE dCurrentDate DATE;
> DECLARE VARIABLE iAutoDefaultDays SMALLINT;
> DECLARE VARIABLE NextPmtDueDate DATE;
> ...
> CurrentDate = CURRENT_DATE;
> iNumOfDays = ((NextPmtDueDate + iAutoDefaultDays) - dCurrentDate);
> ...
>
> In the stored procedure debugger (Database Workbench) I see the
> valuescan add
> NextPmtDueDate = 38092 "Does not look like dCurrentDate below"
> iAutoDefaultDays = 3
> dCurrentDate = 4/30/2004
> iNumOfDays = 38092
>
> It look like the NextPmtDueDate is shown as an integer value, so I
> iAutoDefaultDays to it. But it look like dCurrentDate is NOT an integertoday's
> value and therefore it does not get subtracted from (NextPmtDueDate +
> iAutoDefaultDays)
>
> In other words (38092 + 3) = 38095 but I cannot subtract today's date
> (4/30/2004) from it.
>
> I simply need to add 3 days to the next payment date and subtract
> date form it.return
>
> When I run this through the debugger the procedure will finish and
> "Payment 38095 Days Late"String..."
>
> However when I run it from my app I get a "Conversion Error From
>Michael, dialect 3 is not very familiar to me, so I, out of
> What am I doing wrong?
curiosity, made test database and:
Create procedure Datearithm
Returns (iNumOfDays SMALLINT, dCurrentDate DATE,
iAutoDefaultDays SMALLINT, NextPmtDueDate DATE)
as
begin
dCurrentDate = CURRENT_DATE;
NextPmtDueDate='5/30/2004';
iNumOfDays = ((NextPmtDueDate + iAutoDefaultDays) - dCurrentDate);
Suspend;
end
and
Select * From Datearithm
all worked exactly as in my beloved dialect 1:
INUMOFDAYS DCURRENTDATE IAUTODEFAULTDAYS NEXTPMTDUEDATE
33 30.04.2004 3 30.05.2004
looks like you declared wrong type for one of variables/parameters in
your procedure or on client side, char instead date for example or try
to return time interval into Date. Perhaps smallint is too small to
store iNumOfDays for some NextPmtDueDate. General recommendation -
don't save money buying matches, short types as smallint, float etc
are tribute for times when computer occupied square of swimming-pool
and amount of RAM and disk space was measured in KBytes.
Best regards,
Alexander.