Hi:
I have a Time Card Report I created in Crystal 10. The database I am pulling from displays the hours in decimal time (ie, 1 hr 30 mins is displayed as 1.5). I used the following formula to convert decimal hours to hours/minutes/seconds (where 'regular_hr' field is the time displayed in decimal hours):
Whileprintingrecords;
numbervar DecTime:={regular_hr};
numberVar Totalsecs:=(DecTime*60)*60;
numberVar dur :=Totalsecs;
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
This formula worked great. The problem I'm running into is that once I get the format in hrs/mins/sec I need to round the seconds to hrs/mins only. For example, if the time displays as 2:25:59, I want it to round to 2:26.
Since the field was converted to text, I cannot do this using the Date and Time tab on the Format Editor property sheet.
Any suggestions?
Thanks
I have a Time Card Report I created in Crystal 10. The database I am pulling from displays the hours in decimal time (ie, 1 hr 30 mins is displayed as 1.5). I used the following formula to convert decimal hours to hours/minutes/seconds (where 'regular_hr' field is the time displayed in decimal hours):
Whileprintingrecords;
numbervar DecTime:={regular_hr};
numberVar Totalsecs:=(DecTime*60)*60;
numberVar dur :=Totalsecs;
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
This formula worked great. The problem I'm running into is that once I get the format in hrs/mins/sec I need to round the seconds to hrs/mins only. For example, if the time displays as 2:25:59, I want it to round to 2:26.
Since the field was converted to text, I cannot do this using the Date and Time tab on the Format Editor property sheet.
Any suggestions?
Thanks