I am using Crystal 8.5 on Paradox database. I have an out and back field (both datetime) which I am calculating the duration between the two correctly. So, 9:00 am to 5:00 pm is 8 hours and so forth. So it looks like:
5/1/2012 9:00 AM 5/1/2012 5:00 pm 8:00
5/28/2012 8:00 AM 5/29/2012 6:00 pm 34:00
5/1/2012 6:00 AM 5/1/2012 7:30 pm 13:30
I used the date diff (datediff("s", {Crew.Out},{Crew.Back}) to calculate the total number of seconds for each row and then summed it in the footer. However, when I try to convert this to hours:minutes, the number is way off. In other words if I took my calculator to the above example I get 55:30 total hours, but my conversion is way off (in MY data I add up 179:30 on my calculator but the conversion says 280:29 and all none of my records have 29 minutes).
Here is my conversion formula for the total duration (I commented out seconds):
whileprintingrecords;
numberVar dur:=Sum ({@datediff});
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,"00") + ":" + totext(min,"00");// + ":" + totext(sec,"00");
hhmmss
What am I missing here? Thanks.
5/1/2012 9:00 AM 5/1/2012 5:00 pm 8:00
5/28/2012 8:00 AM 5/29/2012 6:00 pm 34:00
5/1/2012 6:00 AM 5/1/2012 7:30 pm 13:30
I used the date diff (datediff("s", {Crew.Out},{Crew.Back}) to calculate the total number of seconds for each row and then summed it in the footer. However, when I try to convert this to hours:minutes, the number is way off. In other words if I took my calculator to the above example I get 55:30 total hours, but my conversion is way off (in MY data I add up 179:30 on my calculator but the conversion says 280:29 and all none of my records have 29 minutes).
Here is my conversion formula for the total duration (I commented out seconds):
whileprintingrecords;
numberVar dur:=Sum ({@datediff});
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,"00") + ":" + totext(min,"00");// + ":" + totext(sec,"00");
hhmmss
What am I missing here? Thanks.