SQL Server/ASP + arithmetic operations on 'money' datatype *SOLVED*

Mucman

Diamond Member
Oct 10, 1999
7,246
1
0
<code snippet>
sql = "SELECT CAST(SUM(ji.DebitAmount) AS float) AS total "
sql = sql & "FROM ispJournal j, ispJournalItem ji "
sql = sql & "WHERE (j.SourceCustomerKey = '"& arrCkey(I) & "') AND (j.PostDate BETWEEN '"& newsdate & "' AND '"& fdate & "') "
sql = sql & "AND (j.JournalKey = ji.Journalkey) AND (j.Type = 'P')"
'Response.Write(sql)
rs.Open sql,conn_obj,1,3,1
ckeyTotal = Trim(rs("total"))
grandTotal = grandTotal + ckeyTotal
rs.Close

Response.Write("<FONT COLOR=""GREEN"">Done</FONT> $"& ckeyTotal &"
")
</code snippet>

Hopefully the forums don't foul up the formatting too much...

What this query does is return the total amount of payments processed by a certain customer. The query runs fine, and the Response.Write()
call in the end is fine... it prints out the sum of all payments like it should.

If I try to Response.Write(grandTotal) I get nothing... it seems that it loses all integrity ones I perform the addition with the ckeyTotal.

I've tried to google it, but I can't for the life of me find a solution!

<new code snippet>
sql = "SELECT SUM(ji.DebitAmount) AS total "
sql = sql & "FROM ispJournal j, ispJournalItem ji "
sql = sql & "WHERE (j.SourceCustomerKey = '"& arrCkey(I) & "') AND (j.PostDate BETWEEN '"& newsdate & "' AND '"& fdate & "') "
sql = sql & "AND (j.JournalKey = ji.Journalkey) AND (j.Type = 'P')"

rs.Open sql,conn_obj,1,3,1

IF NOT isnull(rs("total")) THEN
ckeyTotal = CDbl(Trim(rs("total")))
END IF


grandTotal = grandTotal + ckeyTotal
rs.Close

Response.Write("<FONT COLOR=""GREEN"">Done</FONT> $"& ckeyTotal &"
")
</new code snippet>

Stupid me!!! Just a couple minutes after post this I figure it out on my own :)