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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I getting the Sum In This Formula

Status
Not open for further replies.

mgkSHA

Programmer
Jul 12, 2002
126
US
Hello:

I have been struggling with this forever and I need one more step to complete this. I have a field on a report that is a string value and I need to add up the values into a sum within a running total field.

I have written the following formulas to convert the string into an integer and then back to the 00:00:00 format within the group footer. What I can't do is get the values to add up within the running total field. How can I do this, what steps did I miss? Where would this formula go? Any advice would be great, because I am ready to give up at this point. Thanks

formula one: in details section of report - - converts the string so I can add up to a sum.

WhilePrintingRecords;
numberVar result;

result := tonumber(left({ado.correctedduration},2))* 3600
+ tonumber(mid({ado.correctedduration},4,2)) * 60
+ tonumber(right({ado.correctedduration},2));

result;


formula two: in group footer of report, returns the value of the RTotal1 Running total field back to 00:00:00

whileprintingrecords;
numberVar dur:=Val({#RTotal1});
numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;

hrs:=Truncate(Truncate(dur/60)/60);
min:=Remainder(Truncate(dur/60),60);
sec:=Remainder(dur,60);

hhmmss:=totext(hrs,"0") + ":" + totext(min, "00") + ":" + totext(sec, "00");

hhmmss

 
Hi,
I am assuming the problem is the the formatting of {#RTotal1} to hh:mm:ss format. In my testing is set "dur" to 7384 which equals 2hr 3min and 4sec. So if {#RTotal1} has the correct value...
Try the following vars:

numbervar dur:= 7384;
numbervar hrs;
numbervar min;
numbervar sec;

hrs:= Truncate(dur / 3600);
min:= Truncate(Remainder(dur,3600) / 60);
sec:= Remainder(Remainder(dur,3600),60);

totext(hrs,"0") + ":" + totext(min,"00") + ":" + totext(sec,"00")

Hope this helps.
 
MrBill:

Where my problem lies is actually getting the running total field, #RTotal1 to "sum up" the group totals. I have the first formula converting the string. The formula in the group footer converts the final product back to 00:00:00. My problem is I need something like this:

String Values parsed into an integer:

00:21:04 - - parsed into 600.23 (or whatever it is)
00:34:12 - - parsed into 745.08
00:12:07 - - parsed into 479.02

Ok, now in the running total field (R#Total1) I need the summed up value 600.23+745.08+479.02.

Get this value and then, re-parse it back to 00:00:00 format (the second formula).

So my headache is, OK, how do I get this RTotal#1 to get a sum value of the parsed strings found in the group.

Any help, I am getting desperate

Martin

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top