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

Division Problem

Status
Not open for further replies.

williadn48

Programmer
Oct 27, 2006
29
US
I need to divide volume by hours to get a productivity total.

The number of scanned images (volume) is 8837. The hours for that total is 06:57. When CR does 8837/6:57, it is reporting 21 mins. Its not right. When I do the formula below on a calculator I get a number that is right.

Here is the formula:
numberVar vol;
numberVar secs;
numberVar productivity;

vol := Sum ({sp_get_Operator_Stats_ByDate_More_Than_One;1.Scan_Imgs}, {sp_get_Operator_Stats_ByDate_More_Than_One;1.operatorid});
secs := Sum ({sp_get_Operator_Stats_ByDate_More_Than_One;1.Scan_Secs}, {sp_get_Operator_Stats_ByDate_More_Than_One;1.operatorid});

if secs <> 0 and vol <> 0 then
productivity := vol/((secs/60)/60)
else
productivity := 0;

numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;

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

hhmmss := totext(hrs,"00") + ":" + totext(min,"00");
 
Hi,
Where does the 6:57 come from and why is it beling used as the divisor, it is not a number..

If it means 6 Hours and 57 minutes then divisor in seconds would be:
(6*60*60) + (57*60) = 25020







[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Againj, don't use productivity as the calcualtion for seconds, it has nothing to do with it.

Ever heard that the definition for insanity is repeating the same process over and over and expecting a different result?

To get the volume, use:

whileprintingrecords;
numberVar vol;
numberVar secs;
numberVar productivity;

vol := Sum ({sp_get_Operator_Stats_ByDate_More_Than_One;1.Scan_Imgs}, {sp_get_Operator_Stats_ByDate_More_Than_One;1.operatorid});
secs := Sum ({sp_get_Operator_Stats_ByDate_More_Than_One;1.Scan_Secs}, {sp_get_Operator_Stats_ByDate_More_Than_One;1.operatorid});

if secs <> 0 and vol <> 0 then
productivity := vol/((secs/60)/60)
else
productivity := 0;
productivity

To get the time in HH:MM:SS use:

whileprintingrecords;
numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;

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

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

OK, last time I try helping you on this, you just keep opening new threads pointlessly that same the same thing...

-k
 
OOops, that should be:

To get the time in HH:MM:SS use:

whileprintingrecords;
numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;

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

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

-k
 
OK. Here is what I have done. Looks like it works now. Sorry for the confusion. I am very stressed with this project and not knowing CR.

numberVar vol;
numberVar secs;
numberVar productivity;

vol := Sum ({sp_get_Operator_Stats_ByDate_More_Than_One;1.Scan_Imgs});
secs := Sum ({sp_get_Operator_Stats_ByDate_More_Than_One;1.Scan_Secs});

if secs <> 0 and vol <> 0 then
vol/((secs/60)/60)
else
0

But I want what ever comes out of this formula to be displayed as hh:mm:ss not as a decimal number.

How do I do that. I have studied synapsevampire's code above but I do not see where I can pass the return value from this formula to synapsevampire's code.

numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;

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

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

sec needs a value in it, right?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top