Focal Point
Converting Minutes to Hours and Remaining Minutes

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4961069122

April 05, 2007, 02:53 PM
<Patch4Ever>
Converting Minutes to Hours and Remaining Minutes
I have a data field called total minutes (Format I4) and need to get two Integer fields split out as a result. One would be hours (total minutes divided by 60) and the other would be the remaining minutes. For example, if there are 500 total minutes, I need an integer field (Hours) that would have a value of 8 and an integer field (Minutes Remaining) that would have a value of 20.
April 05, 2007, 03:07 PM
Leah
quote:
I have a data field called total minutes (Format I4) and need to get two Integer fields split out as a result. One would be hours (total minutes divided by 60) and the other would be the remaining minutes. For example, if there are 500 total minutes, I need an integer field (Hours) that would have a value of 8 and an integer field (Minutes Remaining) that would have a value of 20.


Mathmatically - assumes integer truncation

hours = total minutes / 60
minutes left = total minutes - ( hours * 60 )

Compute or define the values as integers with the above formulas. Should work.


Leah
April 05, 2007, 03:18 PM
Alan B
Try:
DEFINE FILE FN
R1/I4 = MINUTEFIELD;
HOUR/I2 = R1/60;
MIN/I2 = IMOD(R1,60,MIN);
ALPHA_TIME/A5 = EDIT(HOUR)| ':' | EDIT(MIN);
END



Alan.
WF 7.705/8.007
April 05, 2007, 04:05 PM
<Patch4Ever>
I really need the calculation done in the total or subtotal part of the report. The total minutes are for all rows of data. If I do the division on each record, the minutes are all less than 60 so the value will be zero (which is what I get in my total section because of the zeros on each row).
April 05, 2007, 04:13 PM
Danny-SRL
Try using COMPUTE instead of DEFINE and RECOMPUTE for the subtotals.
TABLE FILE FN
PRINT MINUTEFIELD
COMPUTE HOURS/I3=MINUTEFIELD / 60;
COMPUTE MINUTES/I2=MINUTEFIELD - HOURS * 60;
BY SORT1
BY SORT2
ON SORT1 RECOMPUTE
END

Using RECOMPUTE, at total time, instead of simply summing, FOCUS will recalculate HOURS and MINUTES using the total value of MINUTEFIELD.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

April 05, 2007, 04:19 PM
Leah
Or you might try
ON ... SUMMARIZE


Leah