Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Report Sum() fucntion

Status
Not open for further replies.

sahernandez

Programmer
Oct 1, 2002
69
SV
I really new in Crystal Report.
And I need to sum a string that I send from ORACLE.

12:30
00:30
01:30
15:30
25:30
-------------
55:30

How can I use the SUM in my report, cause I don't want to send the sum from the server output.

Thxs
sahernandez
 
It looks like you are trying to sum time spans, and unless I have overlooked something in the past few years there is no function available to do it in CR. try below, you may have to tweak it.

Dim lMinAs number
Dim LHour As number
Dim sTime As String
Dim lSecAs number
dim sHour as string
dim sMinas string
dim sSecas string
dim param as number

param = Sum ({yourFieldToSum})

lSec = tonumber(Mid(cstr(param), InStr(cstr(param), ".") + 1, Len(cstr(param)))) * .60
lMin = tonumber(Left(cstr(param), InStr(cstr(param), ".") - 1))

If lMin > 59 Then
LHour = (lMin / 60)
lMin = lMin Mod 60
else
lHour = 0
End If

sHour = totext(left(cstr(LHour),InStr(cstr(LHour),".")-1))
if len(sHour) < 2 then
sHour = &quot;0&quot; + sHour
end if
sMin = totext(left(cstr(lMin),InStr(cstr(lMin),&quot;.&quot;)-1))
if len(sMin) < 2 then
sMin = &quot;0&quot; + sMin
end if
sSec = totext(left(cstr(lSec),InStr(cstr(lSec),&quot;.&quot;)-1))
if len(sSec) < 2 then
sSec = &quot;0&quot; + sSec
end if

formula = totext(sHour + &quot;:&quot; + sMin + &quot;:&quot; + sSec)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top