Jan 5, 2004 #1 IB12013 IS-IT--Management Jan 5, 2004 1 US i am trying to convert total minutes into hours for example if i had 270 minutes i would like for it to read 4.30 hours any help would be appreciated.
i am trying to convert total minutes into hours for example if i had 270 minutes i would like for it to read 4.30 hours any help would be appreciated.
Jan 5, 2004 #2 Jacque Technical User Nov 9, 2001 301 US Hi IB12013, Try this, note that this will give 00.04.30 not 4.30 although those would be easy changes but this should give you a start: numberVar TotalMinutes := 270; //I'm using your example of 270 minutes here numberVar vhr := int(TotalMinutes/3600); numberVar vrem := remainder(TotalMinutes,3600); numberVar vmin := int(vrem/60); vrem := remainder(vrem,60); numberVar vsec := int(vrem); stringVar dot := "."; stringVar vshr := IIF(vhr<10,"0"+ToText(vhr,0),ToText(vhr,0)); stringVar vsmin := IIF(vmin<10,"0"+ToText(vmin,0),ToText(vmin,0)); stringVar vssec := IIF(vsec<10,"0"+ToText(vsec,0),ToText(vsec,0)); stringVar timestring := vshr+dot+vsmin+dot+vssec; Upvote 0 Downvote
Hi IB12013, Try this, note that this will give 00.04.30 not 4.30 although those would be easy changes but this should give you a start: numberVar TotalMinutes := 270; //I'm using your example of 270 minutes here numberVar vhr := int(TotalMinutes/3600); numberVar vrem := remainder(TotalMinutes,3600); numberVar vmin := int(vrem/60); vrem := remainder(vrem,60); numberVar vsec := int(vrem); stringVar dot := "."; stringVar vshr := IIF(vhr<10,"0"+ToText(vhr,0),ToText(vhr,0)); stringVar vsmin := IIF(vmin<10,"0"+ToText(vmin,0),ToText(vmin,0)); stringVar vssec := IIF(vsec<10,"0"+ToText(vsec,0),ToText(vsec,0)); stringVar timestring := vshr+dot+vsmin+dot+vssec;
Jan 5, 2004 #3 vidru Programmer Jul 18, 2003 2,113 US Try this: Code: NumberVar minutes := 270; int(minutes/60) + ((minutes/60 - int(minutes/60)) * .6) I tried to simplify it using the MOD function, but it was giving me 'fuzzy numbers'. -dave Upvote 0 Downvote
Try this: Code: NumberVar minutes := 270; int(minutes/60) + ((minutes/60 - int(minutes/60)) * .6) I tried to simplify it using the MOD function, but it was giving me 'fuzzy numbers'. -dave
Feb 5, 2004 1 #4 whatisthis123 Programmer Feb 5, 2004 5 US this will work to: Local NumberVar H; Local NumberVar M; Local stringvar HM; H:= fieldname / 60 - .4; //prevents rounding M:= fieldname mod 60 - .4;//prevents rounding if M > 10 then HM:=totext(H,0)+':'+totext(M,0) else //adds preceeding 0 for minutes less than 10 HM:=totext(H,0)+':'+(totext(0,0)+totext(M,0)); Upvote 0 Downvote
this will work to: Local NumberVar H; Local NumberVar M; Local stringvar HM; H:= fieldname / 60 - .4; //prevents rounding M:= fieldname mod 60 - .4;//prevents rounding if M > 10 then HM:=totext(H,0)+':'+totext(M,0) else //adds preceeding 0 for minutes less than 10 HM:=totext(H,0)+':'+(totext(0,0)+totext(M,0));