Subject How do I subtract an integer form a date inside of a stored procedure
Author M Tuttle (KS)
Greetings,

I am trying to subtract today's date (dCurrentDate) from the next payment
date (NextPmtDueDate) less so many grace days (iAutoDefaultDays)

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 following
values
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 can add
iAutoDefaultDays to it. But it look like dCurrentDate is NOT an integer
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 today's
date form it.

When I run this through the debugger the procedure will finish and return
"Payment 38095 Days Late"

However when I run it from my app I get a "Conversion Error From String..."

What am I doing wrong?

Thanks for any pointers...

Michael